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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How do you have defines with specific values using PlayerSettings.SetScriptingDefineSymbolsForGroup

Discussion in 'Scripting' started by crushforth, Feb 12, 2016.

  1. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
    How can I achieve something like this:

    Code (csharp):
    1.  
    2. string[] defines = new string[] {
    3.     "DEBUG",
    4.     "FLURRY_API_KEY=XXXXXXXXXXXX",
    5. };
    6. PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", defines));
    7.  



    If the above example isn't clear, I'm trying to not only define something called FLURRY_API_KEY but I also want it to have a specific value of "XXXXXXXXXXXX". We have many different build configurations on many platforms and I'd like to be able to track them all individually by specifying compile time defines.
     
  2. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
  3. ShadowLiu

    ShadowLiu

    Joined:
    Aug 30, 2012
    Posts:
    17
    I have the same issue,Do you find the way?
     
  4. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
    I ended up doing it like this:


    Code (CSharp):
    1.  
    2. public class BuildSystemConstants {
    3.  
    4.     // Specify per build configuration properties below
    5.  
    6.    
    7.     #if Define1
    8.  
    9.     public static readonly string FlurryAPIKey = "";
    10.     public static readonly string SystemTypeName = "xxxxx";
    11.  
    12.    
    13.     #elif Define2
    14.  
    15.     public static readonly string FlurryAPIKey = "";
    16.     public static readonly string SystemTypeName = "yyyyy";
    17.  
    18.    
    19.     #elif Define3
    20.  
    21.     public static readonly string FlurryAPIKey = "";
    22.     public static readonly string SystemTypeName = "zzzzz";
    23. }
    24. #endif
    25.  
    And in my build script I define either Define1, Define2 or Define3 to activate those configurations
     
  5. ShadowLiu

    ShadowLiu

    Joined:
    Aug 30, 2012
    Posts:
    17
    A little complexity, But it's work, thanks