老师您好!我在学Asset Bundle时,跟着教程走的,在打包时就会如下报错:
报错1:
Assets/NewBehaviourScript.cs(5,4): error CS0246: The type or namespace name `MenuItem' could not be found. Are you missing an assembly reference?
报错2:
Assets/NewBehaviourScript.cs(13,5): error CS0103: The name `BuildPipeline' does not exist in the current context
报错3:
Error building Player because scripts had compiler errors
代码如下:
using System.IO;
using UnityEditor;
public class CreateAB {
[MenuItem("Assets/BuildAB")]
static void BuildAB()
{
string dir = "AssetBundles";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
BuildPipeline.BuildAssetBundles(dir, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
}
请老师解答。
同学你好,同学可以下载一下老师源码进行测试,如果测试工程,再修改回我们的代码去逐一对比测试发现问题,注意命名空间的引入,脚本要放在Editor文件夹下。