Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

关于打包资源存在冗余的问题 #23

Open
cuoyiban opened this issue Oct 30, 2017 · 4 comments
Open

关于打包资源存在冗余的问题 #23

cuoyiban opened this issue Oct 30, 2017 · 4 comments

Comments

@cuoyiban
Copy link

3个资源PrefabA PrefabB ImgC
其中PrefabA 依赖PrefabB 和ImgC,PrefabB 依赖ImgC
打包配置指定PrefabA和PrefabB为root
调试跟踪代码发现,最终生成的依赖关系是:PrefabA -> PrefabB -> ImgC,PrefabA对ImgC的直接依赖会再分析过程Analyze中被优化移除掉。
但是在BeforeExport过程中因为ImgC只有一Root:PrefabB作为其直接子节点,因此ImgC的导出类型AssetBundleExportType还是Asset。然后在实际打包过程中ImgC是不会被单独打包的,但是由于unity5.X的打包机制,unity会保证资源完整性,在PrefabA的AB包和PrefabB的AB包中都会有一份ImgC的存在,存在了冗余。
感觉这里更好的方案是不是ImgC和PrefabB一起打包更加合适一点

@tangzx
Copy link
Owner

tangzx commented Nov 2, 2017

能不能提供一个重现工程?上传到这里就行

@ookcode
Copy link

ookcode commented Apr 21, 2019

到目前为止仍有这个问题,原因在于没有考虑到Root仍然有依赖其他Root的情况,按下列修改即可
private void GetRoot(HashSet rootSet)
{
switch (this.exportType)
{
case AssetBundleExportType.Standalone:
rootSet.Add(this);
break;
case AssetBundleExportType.Root:
rootSet.Add(this);
foreach (AssetTarget item in _dependChildrenSet)
{
item.GetRoot(rootSet);
}
break;
default:
foreach (AssetTarget item in _dependChildrenSet)
{
item.GetRoot(rootSet);
}
break;
}
}

@tangzx
Copy link
Owner

tangzx commented Apr 21, 2019

@ookcode 不开发unity了,这个项目也不维护了。你可以提个pr我来合并一下,谢谢。

@yanyiyun
Copy link

这个问题是预制件嵌套导致, 2018开始支持预制件嵌套, 但是实际上是预制件拷贝. 所以在分析过程中, 出现预制件嵌套, 应该忽略呗嵌套的预制件. 同样的情况出现在.asset文件

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants