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

我主要关心的是,现在我如何在Unity5中获取预制件的目录,然后将它们全部分别转换为自己的单独AssetBundle?不仅是一个包含所有内容的AssetBundle,而是每个内置于其自己单独的AssetBundle的 Assets ?

理想情况下,我将使用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.

最佳答案

新的BuildPipeline.BuildAssetBundlesAssetBundleBuild数组作为输入。您可以创建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)

10-08 16:50