2016-11-05 330 views
-3

This is the problem生成資產束已經過時 - 創建資產時束

C#實施例 從構建在項目視圖中選擇的對象的資產捆綁錯誤獲取。 一旦編譯進入「菜單」 - >「資產」,並選擇選擇 之一來構建資產包

using UnityEngine; 
using UnityEditor; 
public class ExportAssetBundles { 
    [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")] 
    static void ExportResource() { 
     // Bring up save panel 
     string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); 
     if (path.Length != 0) { 
      // Build the resource file from the active selection. 
      Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); 
      BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, 
              BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); 
      Selection.objects = selection; 
     } 
    } 
    [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] 
    static void ExportResourceNoTrack() { 
     // Bring up save panel 
     string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); 
     if (path.Length != 0) { 
      // Build the resource file from the active selection. 
      BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path); 
     } 
    } 
} 
+4

您的問題內容或標題都沒有說明您需要什麼樣的幫助。 [我如何問一個好問題?](http://stackoverflow.com/help/how-to-ask) – melancia

+2

_「不清楚,你的問題是」_ - 尤達 – MickyD

回答

2

如果你讀了錯誤信息,它說,UnityEditor.BuildPipeline.BuildAssetBundle(Object, Object[], string, BuildAssesBundleOptions)是過時的,它表明你應該使用新的AssetBundle系統。

在Unity 5.4b中,有兩個BuildAssetBundles的重載沒有被廢棄。

BuildPipeline.BuildAssetBundles(string outputPath, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform)

BuildPipeline.BuildAssetBundles(string outputPath, AssetBundleBuild[] builds, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform)

使用的這些人,一個和它應該解決您的問題。

每日課程:閱讀錯誤信息。他們可以幫助你很多。

+0

謝謝我做到這一點,但有一個新的問題https://s17.postimg.org/dsf07s7lb/Capture.png –