Skip navigation

Tag Archives: automation

I’ve been working on automating the builds for our Unity project at work and been stymied the past couple of days with the project refusing to compile when I try to build from the command-line.

Here’s the situation, I just want to build a prototype build pipeline for a Unity project for our continuous integration efforts. In order to do that, I need to use Unity’s command line features so that a build server of some flavor can hook in to the Unity application and perform the build automatically.

In order to actually build something executable, in my case a Windows EXE file, the BuildPipeline object needs to be used. Specifically, the BuildPipeline.BuildPlayer function (see the sample code on that page).

Now comes the problem. The UnityEditor library is NOT allowed to be used in a built game! So every attempt at building my simple project resulted in compilation errors. Errors stating:

error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?

After two days of internet searching and following lots of blogs, forums, and youtube videos, I threw my hands up and posted on Stackoverflow. Within a few hours, I had the answer.

Create a folder with the name ‘Editor’, and place your scripts in there. According to the Unity’s Special Folders documentation, scripts place in this folder add “functionality to the Editor during development, and are not available in builds at runtime”.

I also confirmed that the pre-processor wrapping that was suggested worked as well.

So the answer was very easy to implement, but I am still frustrated that this critical piece of information is not made more apparent, especially by Unity’s own documentation.

%d bloggers like this: