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

Preprocessor directive stays defined even after deleting a package

Discussion in 'Scripting' started by StarManta, Jun 10, 2021.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    I have a project with a bunch of different packages. Some of them have conditional references to others, hidden behind #if directives for a symbol that is #define'd in the other package.

    I deleted one of these package, but C# is still acting as if its symbol is defined. I've searched the project, and this symbol only exists throughout the project in #if directives checking for it. Yet, there #if directives are coming back as true, and C# is trying to compile the code inside (and failing because those classes no longer exist).

    Is there something I need to do to make it forget the symbols that have been deleted? Some way to clean out the #define symbols entirely and start from scratch?

    My next step is to Reimport All, but I have no idea if that'll fix it and it'll take hours (plus there's definitely a risk that that might break something else).
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    Sounds like a recompile didn't happen. Try reimport any single script, preferably one in Plugins
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    Found the answer: Apparently, Project Settings -> Player -> Other Settings -> Compilation includes just like, a list of preprocessor directives. For some reason. The culprit was in that list.

    I hope this thread's existence helps some future googler find that absolutely bizarre panel in settings and fix their compilation.
     
    Kurt-Dekker and Michael_Berna like this.
  4. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    804
    For future readers. The reason is that that place is the correct place where define symbols exists for your project. Packages/assets can use code to add their own to that list. I don't believe that there's any system that will remove them once you uninstall a package/asset since you can manually write anything in that list so the system wouldn't know which one was added by a package/asset or which one was manually added.
     
    Michael_Berna and Bunny83 like this.
  5. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    38

    A future Googler has just been helped. Hello from the future and thank you.
     
    StarManta likes this.