Assets/Trismegistus/Core/Tools/ScriptingDefineSymbolsTool.cs
/// <summary>
/// Add or remove #DEFINE symbol from Scripting Define Symbols
/// <example>
/// <code>
/// [UnityEditor.Callbacks.DidReloadScripts]
/// private static void OnScriptsReloaded() {
///	SetSymbol("CUSTOM_SYMBOL", true); }
/// </code>
/// </example>
/// </summary>
/// <param name="symbol"></param>
/// <param name="mode"></param>
/// <param name="group"></param>
/// <returns>Changes have been made</returns>
Add or remove #DEFINE symbol from Scripting Define Symbols


Add or remove #DEFINE symbol from Scripting Define Symbols
public static bool SetSymbol(string symbol, bool mode, BuildTargetGroup group = default) {
			if (group == default) group = EditorUserBuildSettings.selectedBuildTargetGroup;
			var hasSymbol = HasSymbol(symbol, group);
			if (mode == hasSymbol) return false;
			var symbols = GetSymbols(group).ToList();
			if (mode) {
				symbols.Add(symbol);
				Debug.Log($"Added {symbol} define for {group}");
			}
			else {
				var removed = symbols.RemoveAll(x => x.Equals(symbol));
				Debug.Log($"Removed {removed} occurrences of {symbol} define for {group}");
			}
			PlayerSettings.SetScriptingDefineSymbolsForGroup(group, string.Join(";", symbols));
			return true;
		}
public static bool SetSymbol ( string symbol , bool mode , BuildTargetGroup group = default ) { if ( group == default ) group = EditorUserBuildSettings . selectedBuildTargetGroup ; var hasSymbol = HasSymbol ( symbol , group ) ; if ( mode == hasSymbol ) return false ; var symbols = GetSymbols ( group ) . ToList ( ) ; if ( mode ) { symbols . Add ( symbol ) ; Debug . Log ( $" Added  { symbol }  define for  { group } " ) ; } else { var removed = symbols . RemoveAll ( x => x . Equals ( symbol ) ) ; Debug . Log ( $" Removed  { removed }  occurrences of  { symbol }  define for  { group } " ) ; } PlayerSettings . SetScriptingDefineSymbolsForGroup ( group , string . Join ( " " , symbols ) ) ; return true ; }
Add or remove #DEFINE symbol from Scripting Define Symbols
Add or remove #DEFINE symbol from Scripting Define Symbols
Changes have been made
Changes have been made
symbol
string
None
mode
bool
None
group
BuildTargetGroup
None