Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UNITY_EDITOR define grayed-out code

Discussion in 'Scripting' started by IgorAherne, Jul 17, 2018.

  1. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    384
    Just had a funny encounter with Visual studio graying-out everything inside my #if UNITY_EDITOR defines.

    Turns out Visual studio must be in Debug mode, not in Release mode, because macros only work for the Debug mode.

    Original source:
    http://answers.unity.com/answers/668092/view.html
     
  2. SolleXelloS

    SolleXelloS

    Joined:
    Aug 30, 2010
    Posts:
    17
  3. AHAKuo

    AHAKuo

    Joined:
    Apr 15, 2019
    Posts:
    5
  4. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    592
  5. TenaciousDan

    TenaciousDan

    Joined:
    Jul 11, 2019
    Posts:
    22
    I know that Visual Studio does not generate a csproj file for package assemblies. I had a similar issue with a module package I was using that was installed from Git that used UNITY_EDITOR defines. Going to Edit > Preferences > Generate csproj files for: git packages and then regenerating the project files seemed to fix the code being greyed out in VS.
    upload_2023-8-31_23-36-26.png