Should I use #If UNITY_EDITOR?

by Ender Look   Last Updated June 13, 2019 01:13 AM

I found on a tips guide in Unity that I can do:

#if UNITY_EDITOR
do_something()
#endif

And do_something() will only be executed on Unity editor. Even more, when I build the game, that section of the code won't be compiled.

I found that as something very interesting, but when I asked about it to my teacher he said I shouldn't use it... no reason why...

I would like to know from other sources (you) if I should use it or not and why.

Is there anything bad that could produce this? I thought it could be useful for example to use it on DrawGizmos methods since they can only be used on Unity Editor, and you don't need them on a finished product.

Tags : unity c#


Related Questions


Updated July 02, 2019 11:13 AM

Updated July 12, 2015 13:05 PM

Updated July 13, 2015 13:05 PM