Simple debug requirement

Hi all,

As I’m new to Unity I have lots of debug.log, print, debug.line etc.

Rather than commenting them out when not needed (and then uncommenting them again when it goes wrong); is there a simple way to simply not have them included in a build? i.e. they are automatically ignored. Or do I have to:

#define DEBUG true

#ifdef DEBUG
Debug.Log…
#endif

Of course that’s from straight C world :slight_smile:

Cheers

#if UNITY_EDITOR
#else
#endif

That define allows you to only include that code when running from Editor. The Editor usable defines are:
http://unity3d.com/support/documentation/Manual/Platform%20Dependent%20Compilation.html

with C# preprocessor direcives being here:

Even better is the ConditionalAttribute:

This allows you to strip out the calls during build, meaning you don’t have to wrap each call in a #if/#endif

Hey!

That’s great! - thanks a bunch!

Cheers

You could just use a bool, even a static one. Do you think a bunch of if-checks for a bool are going to show up on any performance tests?