Unity/Mono - checking for DEBUG

I’m running via the Unity editor and compiling/debugging via Mono. I read that you can check for DEBUG to isolate code to the Debug configuration (and noticed this as a ‘Define Symbol’ in the Mono project options), so as a test I have this very simple check in my C# script:

#if DEBUG
				Debug.Log("Yay!");
#else		
				Debug.Log("Booo..");
#endif

Unfortunately, regardless of the configuration set in Mono, I always get the Booo path. Does this have something to do with running via the Unity editor (perhaps you lose the Mono preprocessor defines this way)? Is there another way to live-debug that allows for isolating debug code?

Thanks for any feedback.

If you want to isolate debug code, there might be another way to do it.

#if UNITY_EDITOR
Debug.Log("Yay!");
#else
Debug.Log("Booo..");
#endif

That is, assuming Unity Editor is always for debugging code, and any other platform is your “release” platform.

Reference: Unity - Manual: Conditional Compilation

You can use Global Custom Defines to code this way. Look at the bottom of the page: Unity - Manual: Conditional Compilation

Unity does not use MonoDevelop configurations to compile your code.
If you want special code for debug versions, use

if (Debug.isDebugBuild) {
    Debug.Log("Yay!");
}
else {
    Debug.Log("Booo...");
}

However, know that this adds an extra if statement at runtime and the running code in the editor always returns Debug Build to be true.

More information is at http://unity3d.com/support/documentation/ScriptReference/Debug-isDebugBuild.html

You also could use [System.Diagnostics.Conditional(“Something”)] to disable or able any function in c#.
“Something” should be defined in “BuildSettings-> PlayerSettings->Scripting Define Symbols”.