| Parameter | Description |
|---|---|
| buildTarget | The NamedBuildTarget. |
Gets the array of symbols for script compilation for the build target you select. Symbols are semicolon-separated. For example, "SYMBOL1;SYMBOL2".
This method returns only the symbols stored in the Player settings. It doesn't include the symbols that an active build profile adds through BuildProfile.scriptingDefines.
Unity compiles scripts against both sets of symbols. To get the symbols that the active build profile contributes, read BuildProfile.scriptingDefines on that profile.
using UnityEditor; using UnityEditor.Build; using UnityEngine;
public class GetScriptingDefineSymbolsExample { [MenuItem("Tools/Log Scripting Define Symbols")] static void LogScriptingDefineSymbols() { // Using built-in constants. string standaloneDefines = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.Standalone); UnityEngine.Debug.Log("Standalone: " + standaloneDefines);
// Migrating from BuildTargetGroup. NamedBuildTarget namedTarget = NamedBuildTarget.FromBuildTargetGroup(BuildTargetGroup.Android); string androidDefines = PlayerSettings.GetScriptingDefineSymbols(namedTarget); UnityEngine.Debug.Log("Android: " + androidDefines); } }
Gets the array of user-specified symbols for script compilation for the build target you select.
This overload returns only the symbols stored in the Player settings. It doesn't include the symbols that an active build profile adds through BuildProfile.scriptingDefines.