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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Adding compilation symbol in Unity IL2Cpp build solution

Discussion in 'Windows' started by AnandSG, Dec 4, 2019.

  1. AnandSG

    AnandSG

    Joined:
    Oct 5, 2018
    Posts:
    9
    i'm building a App for UWP, before when i use to build it using .net scripting backend i use to add my Conditional compilation symbol at project properties > Build > General > Conditional Compilation symbols.
    upload_2019-12-4_19-4-54.png

    But now i cant find any option to add it when i build my project using IL2Cpp scripting bakend.
    Though i tried to add it here
    upload_2019-12-4_19-5-43.png
    upload_2019-12-4_19-6-56.png

    But it didn't work for me , the code comes under defined symbol is not compiling.
     
  2. timke

    timke

    Unity Technologies

    Joined:
    Nov 30, 2017
    Posts:
    395
    For C++ projects in Visual Studio, the "Preprocessor Definitions" setting is the proper place for your defines. From this information it isn't clear why it's not working.

    Only suggestion I can think of: are you using the correct C++ Preprocessor macros and/or syntax?

    I assume you want some "debug only" code, but you shouldn't need to manually define the macros as VS automatically defines them via compiler switches. See this SO post for more context: https://stackoverflow.com/questions/2290509/debug-vs-ndebug. Also keep in mind, C++ macros can be #undef'd if code; so make sure this isn't happening.

    For the IL2CPP project, you shouldn't need to add any defines there. However, if you do want to manually change the generated code and add your of defines (not recommended), you'll have to do this via the "Build Command Line". Since IL2CPP is built by an external compiler, VS doesn't provide a "real" Preprocessor Definitions option box because it doesn't know how to pass these parameters. The option you see is only for adding defines for IntelliSense within the IDE, so you don't get the red squiggly lines.
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,518
    Can you show exactly what you add to "Preprocessor Definitions" and how you check for that define in code?
     
  4. AnandSG

    AnandSG

    Joined:
    Oct 5, 2018
    Posts:
    9
    upload_2019-12-5_12-56-12.png

    In Script :
    upload_2019-12-5_13-0-52.png
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,518
    Where is your script located? That code looks like C# rather than C++.
     
  6. AnandSG

    AnandSG

    Joined:
    Oct 5, 2018
    Posts:
    9
    yes, its a c# script , for Hololens i'm building this using Il2Cpp scripting backend ,and the script is from my unity project .
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,518