After importing some assets from the store, I get the warning “Unity Editor class not found” as a compiling error. The offending scripts are from those assets.
Any idea?
scripts are in the wrong place in the project? I believe all editor scripts need to be in folders called “Editor”
I already checked that, but it wasn’t the problem.
Thanks.
I just had this problem yesterday. In Unity, you can have a code file import the UnityEditor namespace; but when you go to build it, it will give you the ‘UnityEditor class not found’ error you reference above.
It takes careful testing to catch stuff like this.
My problem was, I needed to know the AssetDatabase path of a gameObject, at runtime. The code I created threw errors at runtime, that didn’t exist at design. It was that same error ‘UnityEditor not found’ you reference above.
I finally took the logic out of the class, and put it in a class, in the UnityEditor folder. I have responsibility for loading/saving objects split between two classes now, which is not good - but it’s kind of forced on you when UnityEditor isn’t available at runtime.
Thanks for the information.
UnityEditor is not available in builds (which makes sens).
If you are using this namespace, place your script into a Editor folder (folders named “Editor” are not included in builds). This will highlight the errors from the editor so you will know about the errors before building.
Also, you could use:
#if UNITY_EDITOR
// Code that makes use of UnityEditor
#endif
To exclude portions of code from your builds.