使用“UnityEditor” ,build时报错error CS0246

使用“UnityEditor” ,build时报错error CS0246

问题描述
在代码中使用UnityEditor,在调试运行时并没有任何错误,可在Build发布时报错如下:
“error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing a using directive or an assembly reference?”

解决方法
  UnityEditor编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 “using UnityEditor”引用。如果想使用该脚本,需要把脚本放到工程目录下的Assets/Editor文件夹下,或者在工程目录Assets下新建Editor文件夹,并将脚本放到Editor文件夹内。
就可以解决该问题。

参考:https://stackoverflow.com/questions/40064746/the-type-or-namespace-name-unityeditor-could-not-be-found

你可能感兴趣的:(unity)