2015-03-08 22 views
6

Vì vậy, tôi đã đọc qua các thay đổi Unity5 AssetBundle và hiểu chúng hoàn toàn. Vấn đề của tôi là rất nhiều chức năng đã được thực hiện 'lỗi thời', nhưng các chức năng dường như vẫn hoạt động và tài liệu Unity5 thực sự đang sử dụng các chức năng lỗi thời.Unity5 AssetBundle chức năng lỗi thời?

Mối quan tâm chính của tôi là, bây giờ tôi sẽ làm thế nào, trong Unity5, hãy lấy một thư mục prefabs và biến tất cả chúng thành AssetBundles riêng biệt của riêng họ? Không chỉ một AssetBundle chứa tất cả mọi thứ, mà đúng hơn là mỗi AssetBundle được tích hợp vào riêng nó?

Lý tưởng nhất là tôi sẽ sử dụng chức năng BuildPipeline.BuildAssetBundle. Nhưng unity5 nói rằng đã lỗi thời. Nhưng nếu bạn nhìn vào đây: http://docs.unity3d.com/500/Documentation/Manual/managingassetdependencies.html

Chúng đang sử dụng chức năng đó trong sách hướng dẫn.

Ngoài ra, tùy chọn CollectDependencies đã lỗi thời và không còn cần thiết nữa. Nhưng tôi lấy nó từ mã của tôi và sau đó Unity nhổ ra lỗi:

Please specify BuildAssetBundleOptions.CollectDependencies or collect GameObject's components and pass as 'assets' parameter. 

Trả lời

5

mới BuildPipeline.BuildAssetBundles mất một mảng AssetBundleBuild như đầu vào. Bạn có thể tạo một AssetBundleBuild[] và điền vào nó với tất cả các prefabs bạn muốn, như các gói riêng biệt:

//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) 
Các vấn đề liên quan