BuildPipeline.BuildAssetBundle()
  将Project文件夹中的任意个Assets打包成一个AB,一般适用于对单个大规模场景的细分
BuildPipeline.BuildStreamedSceneAssetBundle()
  将一个或多个场景中的资源及其所有依赖打包成一个AB,一般适用于对单个或多个场景进行集中打包
BuildPipeline.BuildAssetBundleExplicitAssetNames()
  将Project文件夹中的任意个Assets打包成一个AB,可以为该AB中的每个Asset命名

 

CompleteAssets
  使每个Asset本身完备化
CollectDependencies
  包入每个Asset依赖的所有资源
DeterministicAssetBundle
  使每个Object具有唯一的、不变的Hash ID,便于后续查找,可用于增量式发布Asset Bundle
UncompressedAssetBundle
  不进行数据压缩

 

下载远端服务器的ab,同时可以通过其属性加载资源

string Path = "file:///E:/Work/LLClient/Main/assetbundles_android/Pet/";
WWW www = new WWW (Path + "pet_50010.assetPrefab");
while(!www.isDone)
{
yield return null;
}
var charLoaded = Instantiate(www.assetBundle.mainAsset) as GameObject;

string Path = "file:///E:/Work/LLClient/Main/assetbundles_android/Pet/";
WWW www = WWW.LoadFromCacheOrDownload (Path + "pet_50010.assetPrefab",2);
while(!www.isDone)
{
yield return null;
}
var charLoaded = Instantiate(www.assetBundle.mainAsset) as GameObject;

 

 

加载ab资源

AssetBundle.CreateFromMemory()
从内存数据流动态创建AB
AssetBundle.CreateFromFile()
从磁盘文件动态创建AB,仅支持非压缩的AB

 

加载任意AB中的Assets
AssetBundle.Load()
加载AB中指定名字的Object
AssetBundle.LoadAsync()
异步加载AB中指定名字的Object
AssetBundle.LoadAll()
加载AB中的所有Objects

 

AssetBundle.Unload(false)
仅释放Asset Bundle本身
AssetBundle.Unload(true)
释放Asset Bundle以及从它加载的Assets
Resource.UnloadUnusedAssets()
仅释放没有引用的Assets

 

建立AB 之间的依赖
• 建立依赖
• BuildPipeline.PushAssetDependencies()
• BuildPipeline.PopAssetDependencies()
(同时适用于BuildAssetBundle和BuildStreamedSceneAssetBundle)
• 顺序加载
• 必须严格按照依赖关系进行加载
• 例如Mat à Cube/Cylinder
• 如需增量式发布
• DeterministicAssetBundle选项

 

posted on 2016-06-07 11:14  AlanE  阅读(643)  评论(0编辑  收藏  举报