2016-11-05 97 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 –