• AssetBundle


    1.  生成 AssetBundle 文件

      Editor 文件夹下添加代码:

     1 [MenuItem("Assets/Build AssetBundles")]
     2     static void BuildAllAssetBundles()
     3     {
     4         string assetBundleDirectory = "Assets/AssetBundles";
     5         if(!Directory.Exists(assetBundleDirectory)
     6         {
     7             Directory.CreateDirectory(assetBundleDirectory);
     8         }
     9         BuildPipeline.BuildAssetBundles(assetBundleDirectory,         
    10         BuildAssetBundleOptions.None, BuildTarget.Standalone);
    11     }    

    2. 划分文件夹

      指定 AssetBundle 时文件夹之间用 / 分开。

    3.  加载资源

    1 function Start() {
    2    var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));
    3    if (myLoadedAssetBundle == null) {
    4        Debug.Log("Failed to load AssetBundle!");
    5        return;
    6    }
    7    var prefab = myLoadedAssetBundle.LoadAsset.<GameObject>("MyObject");
    8    Instantiate(prefab);}

    4. AssetBundle 分组策略

      

      

    4. AssetBundle 的使用

      

    5. AssetBundleManifest 使用

    1 AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestFilePath);
    2 AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
    3 string[] dependencies = manifest.GetAllDependencies("assetBundle"); //Pass the name of the bundle you want the dependencies for.
    4 foreach(string dependency in dependencies)
    5 {
    6     AssetBundle.LoadFromFile(Path.Combine(assetBundlePath, dependency));
    7 }

     6. AssetBundle 卸载

    AssetBundle.Unload(bool);

       

    7. AssetBundle 浏览工具

       Unity Asset Bundle Browser tool。

      

  • 相关阅读:
    lr如何获取当前系统时间戳
    linux创建用户、设置密码、修改用户、删除用户
    Linux下安装load generator步骤及问题解决
    怎么将手动设定的IP变成固定的自动IP.
    Redis与Memcached的区别
    memcached 下载安装
    linux上传下载文件rz,sz
    oracle错误码
    sharepoint 2013 附件控件FileUpload怎样检验是否为图片的方法
    10gocm-&gt;session3-&gt;数据备份与恢复
  • 原文地址:https://www.cnblogs.com/coderJiebao/p/unity3d07.html
Copyright © 2020-2023  润新知