Scripts in Plugins/Folder/Editor are included in build?

I have a property drawer at Assets/Plugins/Loius/Editor/DisplayIfDrawer.cs

When I try to build, “the type or namespace UnityEditor could not be found” for this file (and other files in similar locations that require UnityEditor).

I thought that Editor folders (or at least scripts inside them) were omitted from the build? Why do I have to add #if UNITY_EDITOR to these files but not to things in Assets/Editor?

Is this a bug I should report or is there some interaction I’m unaware of?

You cannot place certain special folders inside other special folders and have them work as intended. Placing and “Editor” folder inside the “Plugins” folder will not work as intended.

Use the Special Folders only for their intended use to avoid this:


Unity lets you add Plugins to a project to extend the features available to Unity. Plugins are native DLLs that are typically written in C/C++. They can access third party code libraries, system calls and other things that are not provided by Unity out of the box. Plugins must be placed in a folder called Plugins to be detected by Unity and like the Editor folder, this affects the order in which scripts are compiled. See the page on Special Folders and Script Compilation Order for further details.