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
本文详细解释了在Unity项目中遇到的Thetypeornamespacename`UnityEditor'couldnotbefound.错误,并提供了如何将编辑器脚本正确放置于Assets/Editor目录下的解决方案。
2067

被折叠的 条评论
为什么被折叠?



