Page 1 of 1
Properly excluding editor from Unity build
Posted: 25 Mar 2021, 07:24
by Rocko Bonaparte
I tried to do a test build of my project and slammed into a bunch of editor-only Noesis code that got dragged into the build. This is a lot of stuff in Assets\NoesisGUI\Plugins\Editor. For example of just one in one file:
Assets\NoesisGUI\Plugins\Editor\NoesisMenu.cs(7,18): error CS0234: The type or namespace name 'MenuItemAttribute' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
It's an editor-only thing and doesn't have a preprocessor definition around it. Nonetheless, I assume it should be excluded. Is there an assembly definition or something I should be hunting down?
Re: Properly excluding editor from Unity build
Posted: 25 Mar 2021, 16:24
by jsantos
Everything inside
Editor folders is considered by Unity as editor-only by default. We have plans (
#1827) to deprecate the .unitypackage and move to the new Package Manager + assembly definition.
Re: Properly excluding editor from Unity build
Posted: 25 Mar 2021, 18:25
by Rocko Bonaparte
I am assuming I have some inconsistency in project structure or settings then, but I wouldn't know what. If I am building code in Visual Studio then I am okay. Within the editor and play mode, I am okay. However, when I try to build a game executable (for Windows), then Unity wants to treat those files as if they should be built too.
It looks like it only does this with Noesis. I have a few other assets that it doesn't complain about. I would note Odin Inspector because that is all editor-side for me. I think they are using the newer paradigm so that's probably irrelevant though.
All I can really think is that I have a using directive that drags in this editor-side stuff somewhere, but I couldn't readily tell where. I am guessing it is an uncommon problem so I will dig some more. I rarely do full game builds so I am poorly-versed in all the ways that uniquely goes wrong.
Re: Properly excluding editor from Unity build
Posted: 25 Mar 2021, 20:45
by jsantos
Probably adding assembly definitions will solve your problem. A few clients are already doing that till it happens officially.
Re: Properly excluding editor from Unity build
Posted: 27 Mar 2021, 08:03
by Rocko Bonaparte
For reference for others in the future, it means adding an assembly definition for the Assets/NoesisGUI/Plugins/Editor folder. It needs to depend on the parent NoesisGUI assembly definition (I think it came with it or else I created one at some point?). The editor one needs to include only for the Editor platform.