Tag Archives: Scripting Define Symbols (

Small function: dynamic change of scripting define symbols (macro definition) by unity

Objective:

Add a new macro definition to an existing macro definition

//Get which platform you are currently on
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;

//Get macro definitions that are already available for the current platform
var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
            
//Add the macro definition you want
if (!symbols.Contains("SARF"))
{
    string str = "";
    str = symbols + ";SARF";

    PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, str);
}