Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Add ability to toggle DEBUG and UNITY_EDITOR directives

Discussion in 'Editor & General Support' started by IC_, Feb 8, 2019.

  1. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    61
    I've stucked into a problem when my editor compiles application well while release could'n compile due to some parts of important code was in #if DEBUG #endif directives. It would be cool if I could disable DEBUG temporary to check what piece of code fails to compile

    And the same is for UNITY_EDITOR. Sometimes IDE adds using UnityEditor; statements implicitly and release build fails too

    Is this possible now?
     
  2. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    to disable DEBUG temporarily, press ctrl+shift+h in visual studio and globally replace DEBUG with something like DEBUG_DISABLED :D
    don't forget to check "case sensitive"
     
    IC_ likes this.
  3. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    61
    All ingenious is simple. Thanks :)
     
  4. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    61
    Not really a good solution. Dancing around regex caused me to revert back a lot of stuff that is not meant to be changed like comments or constants or something. Need built-in solution
     
  5. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    I'm not sure you can disable the built-in DEBUG, but you can define your own symbols in Project settings → Player

    upload_2019-2-22_17-15-44.png

    Replace DEBUG in your code with something like MY_DEBUG and enable/disable it in this field
     
    IC_ likes this.