Unity发布时出现“The type or namespace name `UnityEditor' could not be found.” 错误
这说明是编辑器脚没有放到目录文件夹 Assets/Editor的目录下。
如果是想在在非编辑器脚本中加入UnityEditor的相关代码,需要这样:
#if UNITY_EDITOR
//用到编辑器的代码
#endif
例如:
#if UNITY_EDITOR
UnityEditor.TextureImporter te = (UnityEditor.TextureImporter)UnityEditor.TextureImporter.GetAtPath(UnityEditor.AssetDatabase.GetAssetPath(text1));
te.textureType = UnityEditor.TextureImporterType.Advanced;
te.isReadable = true;
te.npotScale = UnityEditor.TextureImporterNPOTScale.None;
#endif