首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Unity5 AssetBundle函数过时了吗?

Unity5 AssetBundle函数过时了吗?
EN

Stack Overflow用户
提问于 2015-03-08 12:13:23
回答 1查看 4K关注 0票数 7

因此,我已经通读了Unity5 AssetBundle的更改,并完美地理解了它们。我的问题是,很多功能已经“过时”了,但这些函数似乎仍然有效,而且Unity5文档实际上正在使用过时的函数。

我主要关心的是,我现在如何在Unity5中获取预制件的目录,并将所有预制件分别转换为各自独立的AssetBundles?不只是一个包含所有内容的AssetBundle,而是每个内置于它自己单独的AssetBundle中?

理想情况下,我会使用BuildPipeline.BuildAssetBundle函数。但unity5说,这已经过时了。但是如果你看这里:http://docs.unity3d.com/500/Documentation/Manual/managingassetdependencies.html

他们正在使用手册中的那个功能。

此外,它还说CollectDependencies选项已经过时,不再需要。但是我从我的代码中删除了它,然后Unity吐出了错误:

代码语言:javascript
复制
 Please specify BuildAssetBundleOptions.CollectDependencies or collect GameObject's components and pass as 'assets' parameter.
EN

回答 1

Stack Overflow用户

发布于 2015-05-05 20:10:13

新的BuildPipeline.BuildAssetBundles接受AssetBundleBuild数组作为输入。您可以创建一个AssetBundleBuild[],并在其中填充您想要的所有预制组件,作为单独的捆绑包:

代码语言:javascript
复制
//Create an array for 2 different prefabs.
AssetBundleBuild[] buildMap = new AssetBundleBuild[2];

//Make a buildMap for the first prefab.
AssetBundleBuild buildInfo1 = new AssetBundleBuild();
//The name of the bundle that the prefab will be saved as.
buildInfo1.assetBundleName = bundle1Name+".unity3d";

//Only one file for this prefab.
string[] prefabs1 = new string[1];
//The full path to the prefab.
prefabs[0] = prefab1Path;
buildInfo1.assetNames = prefabs1;

buildMap[0] = buildInfo1;


AssetBundleBuild buildInfo2 = new AssetBundleBuild();
//The name of the bundle that the prefab will be saved as.
buildInfo2.assetBundleName = bundle2Name+".unity3d";

//Only one file for this prefab.
string[] prefabs2 = new string[1];
//The full path to the prefab.
prefabs[0] = prefab2Path;
buildInfo2.assetNames = prefabs2;

buildMap[0] = buildInfo2

//Save the prefabs as bundles to the "bundleFolder" path.
BuildPipeline.BuildAssetBundles(bundleFolder, buildMap)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28922995

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档