What happens when the game is built and runs outside of Unity?

Probably we don’t need those numbers in the final build at all but my main concern is that accessing of things from “UnityEditor” namespace. In a standalone build those should not be even available, right?

If so, can we somehow make this script automatically removed when building the game?

Hi anula,

UnityEditor refers to the Unity editor only, not to the build. The code simply won’t work in the build.

Unfortunately, I don’t know if there is a way to automatically remove specific code from your scripts. Please feel free to ask our helpful community of students over on our Discord chat server.


See also:

Hi @anula,
We address this problem a couple of times during later lectures, so don’t worry too much for now.
By the end of the section, you will have replaced all of the editor-specific code in CoordinateLabeler.cs.

I’m using unity 2020.2.1f1 and I noticed that after I wrote the Awake() and DisplayCoordinates() functions, when I returned to Unity I got errors because label was null. To fix this I reopened Unity and when the project was loaded again the code worked as it should and it continue to work even after making changes to the class. Was there something that I missed that caused the errors or it’s because of Unity version ?

Sounds like a serialization issue to me @Flajavin, especially if they went away after you reloaded the project.
This can happen from time to time and you’ll eventually get used to spotting serialization errors. Just reload the project to see if solves them first and potentially save yourself hours of tearing your hair out!

Privacy & Terms