Jonny
Jonny

Reputation: 16338

Unity 4.6, run in debug mode

How can I run the current game inside the Unity editor in debug mode - as in preprocessor variable DEBUG will be true/enabled for scripts. I normally have a lot of:

#if DEBUG
dostuffonlyindebuglikegetalotofmoneyingame();
#else
// release mode
#endif

scattered around my projects. Using Unity 4.6 RC3.

Upvotes: 1

Views: 1743

Answers (2)

Krzysztof Bociurko
Krzysztof Bociurko

Reputation: 4661

You can have global #defines with one of these methods:

  1. build settings, per platform
    enter image description here

    also available via build script: PlayerSettings.SetScriptingDefineSymbolsForGroup

  2. Global Custom Defines

  3. For debug, maybe a check for UNITY_EDITOR is enough?

Upvotes: 1

Jonny
Jonny

Reputation: 16338

I found this:

http://docs.unity3d.com/460/Documentation/ScriptReference/Debug-isDebugBuild.html

Not sure yet but it seems not very good because:

  • As this is a runtime check, it would probably get debug code into release builds... affecting performance as well as stability and your reputation ;-)
  • The only supported mode in the Unity "Game" mode is the Debug one. This really sucks. Deploying to devices to test release builds just takes too long time because deployment is SLOW, at least on my box. :-(
  • Any #if DEBUG etc you wrote so far can't be used. You would have to replace that with the runtime calls Debug.isDebugBuild ... not pretty.

Not sure if Debug.isDebugBuild is removed on release builds or not... if not, Unity sucks :-)

That said, this might be the only option... poor us.

Upvotes: 0

Related Questions