纳金网

标题: 关于u3d打包assetbundle [打印本页]

作者: may    时间: 2015-11-19 06:46
标题: 关于u3d打包assetbundle

一、  同一个 BuildPipeline.PushAssetDependencies(); BuildPipeline.PopAssetDependencies(); 内包裹的的打包资源有依赖关系,可能是和BuildAssetBundleOptions有关系。如下前后打包的atlas是有依赖关系的。加载时只加载最后生成的assetbundle,是不会显示的,必须先加载出第一个。
  1. BuildPipeline.PushAssetDependencies();
  2. for (int i = 0; i < _atlas.Length; i++)
  3.             {           
  4.                 targetPathName = targetPath + target.ToString().ToLower() + "_" + _atlas[i].name + ".assetbundle";   //assetbundle存放的目标路径

  5.                 bool be = BuildPipeline.BuildAssetBundle(_atlas[i], null, targetPathName, options, target);   //将图集分别打包

  6.                 Debug.Log(be);

  7.             }
  8. BuildPipeline.PopAssetDependencies();
复制代码
二、BuildAssetBundleOptions。

使用BuildAssetBundleOptions.UncompressedAssetBundle 打包不会压缩资源,因此一般图集包选这个会很大的,所以一般不会选。
使用AssetBundle.CreateFromFile(string) 此同步方法读取assetbundle,此assetbundle包必须是BuildAssetBundleOptions.UncompressedAssetBundle生成的非压缩的包。
因此打包的时候应根据需要权衡哪些需要UncompressedAssetBundle,哪些不需要UncompressedAssetBundle。
也可以分不同的方式读取,一些用www,一些用AssetBundle.CreateFromFile。


作者: tianziqiao    时间: 2016-3-9 15:01
学习了 谢谢分享




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5