ABSystem icon indicating copy to clipboard operation
ABSystem copied to clipboard

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

Open cuoyiban opened this issue 8 years ago • 4 comments
trafficstars

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一起打包更加合适一点

cuoyiban avatar Oct 30 '17 06:10 cuoyiban

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

tangzx avatar Nov 02 '17 01:11 tangzx

到目前为止仍有这个问题,原因在于没有考虑到Root仍然有依赖其他Root的情况,按下列修改即可 private void GetRoot(HashSet<AssetTarget> 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; } }

ookcode avatar Apr 21 '19 01:04 ookcode

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

tangzx avatar Apr 21 '19 02:04 tangzx

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

yanyiyun avatar Jul 27 '20 02:07 yanyiyun