unity5.x ab包读取方式

 

一 读取整个依赖关系

1 文件目录结构 

unity5.x ab包读取方式_第1张图片unity5.x ab包读取方式_第2张图片

2 读取代码

  [MenuItem("Build/Read BuildBundles")]
        static void ReadAssetBundles()
        {
            string path = "C:/Project/AssetBundleTest/Assets/bundles/assetbundle/assetbundle";
            if (!File.Exists(path))
                return;


            AssetBundle assetBundle = AssetBundle.LoadFromFile(path);
            if(assetBundle != null)
            {
                AssetBundleManifest asstBundleManiFest = assetBundle.LoadAsset("assetbundlemanifest"); //打包路径
                assetBundle.Unload(false);
                if(asstBundleManiFest != null)
                {
                    string[] dependsFile = asstBundleManiFest.GetAllDependencies("cube.ab");
                    for (int i = 0; i < dependsFile.Length; i++)
                    {
                        Debug.Log("Name:" + dependsFile[i].n);
                    }
                }
            }
           
        }

 

读取结果: 

 

你可能感兴趣的:(unity)