Unity5 AssetBundle功能已经过时了吗?

ryg*_*go6 7 unity-game-engine

所以我已经阅读了Unity5 AssetBundle的变化,并完全理解它们.我的问题是许多功能已经"过时",但功能似乎仍然有效,Unity5文档实际上使用的是过时的功能.

我主要担心的是,我现在如何在Unity5中获取一个预制件目录并将它们全部分别转换为各自独立的AssetBundles?不只是一个包含所有东西的AssetBundle,而是每个都包含在它自己独立的AssetBundle中?

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

他们正在手册中使用该功能.

此外,它表示CollectDependencies选项已过时,不再需要.但我从我的代码中删除它然后Unity吐出错误:

 Please specify BuildAssetBundleOptions.CollectDependencies or collect GameObject's components and pass as 'assets' parameter.
Run Code Online (Sandbox Code Playgroud)

Ras*_*sen 5

new BuildPipeline.BuildAssetBundles将AssetBundleBuild数组作为输入.您可以AssetBundleBuild[]使用所需的所有预制件创建并填充它,作为单独的捆绑包:

//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)
Run Code Online (Sandbox Code Playgroud)