Unity AssetBundle的依赖描述深度测试

2023-07-13  本文已影响0人  Pieces_Jing

问题:
假设我们有3个AssetBundle,分别是A、B、C。他们的依赖关系是A依赖B、B依赖C。那么当我们打包后,通过Manifest去读取A的依赖文件清单时,是否会有C呢?
结论:

代码:

    [MenuItem("Test/BuildAB")]
    public static void Build()
    {
        Directory.CreateDirectory("AssetBundles");
        var manifest = BuildPipeline.BuildAssetBundles("AssetBundles", BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
        foreach(var ab in manifest.GetAllAssetBundles())
        {            
            //Debug.Log($"[{ab}] 依赖的文件:");
            var depends = manifest.GetAllDependencies(ab);
            foreach(var depend in depends)
            {
                Debug.Log($"[{ab}] 依赖文件: {depend}");
            }
        }

        Debug.Log($"Over");
    }

输出:


image.png
上一篇下一篇

猜你喜欢

热点阅读