"UnityEditor" namespace not found...

This happens only when I try to build the project, when I run Unity no error shows.
(Actually it crashes)

Any idea? Thanks.

Hello, have you tried using platform dependent compilation?

I was having a similar problem with one of my scriptable objects. My scriptable object was not an editor script, but it had OnInspectorGUI code in it (used so I only had to write the inspector gui for the scriptable object once).

I fixed the issue by putting #if UNITY_EDITOR before the using UnityEditor directive and #endif after it. You will also need to surround your GUI code with these same tags.

Hope this helps!

You have to place this script in a directory called “Editor” in the root of your project hierarchy.

Built game cannot use the UnityEditor namespace. This namespace comes with the UnityEditor.dll assembly that is not shipped (and not compatible) with any build made by Unity.

Scripts that use this namespace are only meant to be executed inside Unity Editor.

The problem is:
The namespace “UnityEditor” can only be used if you are in the Unity Editor program. I have the same Problem, too. But I need the “using UnityEditor” for one of my scripts to load files from assets.

Had the same problem, cause I have changed the location of the Orthello to be under plugins folder, when I moved it back to be under the ‘Assets’ folder, it fix it.

Just move editor script to “Editor” folder.
: (
So ugly Unity

Create folder named Editor and save your .cs file in that Editor folder.

I have the same problem but when I try what @Seth-McCumber suggested the script doesn’t run. Does anyone know how to fix this. The script needs to use “UnityEditor” so I really have no idea how to fix this.

A better way to do this is quite simple. This is if the entire Monobehaviour is needed only in the editor. Put #if UNITY_EDITOR before using UnityEditor; and #endif at the very end of the code.