Simple question but couldn’t seem to locate a definitive answer… Are functions like OnDrawGizmos or OnDrawGizmosSelected ever called when running a build? I assume they only run inside the editor in scene view but I just want to be sure! I have an OnDrawGizmos helper function that’s doing a lot of GameObject.Find and would be disastrous if it runs in the build.
No, they won’t be executed in a build
You can also use the Conditional attribute to make sure the function is excluded from the build:
[Conditional("UNITY_EDITOR")]
void OnDrawGizmos()
{
// ...
}
It’s the same as:
#if UNITY_EDITOR
void OnDrawGizmos()
{
// ...
}
#endif