1.在UnityEditor的时候要把Assets同级目录下的Editor文件夹里,如果没有就创建一个Editor文件夹里。
2.或者在unity中找到UnityEditor.dll,然后放到Assets里。
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class createAssetsBundle { [MenuItem("MyTools/CreateBundleWindows")] public static void CreateBundleWindows() { string outPath = Application.streamingAssetsPath + "/Windows/"; Debug.Log(outPath); BuildPipeline.BuildAssetBundles(outPath,0,BuildTarget.StandaloneWindows64); } [MenuItem("MyTools/CreateBundleAndroid")] public static void CreateBundleAndroid() { string outPath = Application.streamingAssetsPath + "/Android/"; Debug.Log(outPath); BuildPipeline.BuildAssetBundles(outPath,0,BuildTarget.Android); } }