using UnityEditor; using System.Collections.Generic; using System.Linq; namespace NRKernal.Release { static class DefineSymbolsUtility { public static bool HasSymbol(string symbol) { string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); return (!string.IsNullOrEmpty(definesString) && definesString.Contains(symbol)); } public static void RemoveSymbol(string symbol) { string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); List allDefines = definesString.Split(';').ToList(); allDefines.Remove(symbol); PlayerSettings.SetScriptingDefineSymbolsForGroup( EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", allDefines.ToArray())); } public static void AddSymbol(string symbol) { string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); List allDefines = definesString.Split(';').ToList(); List Symbols = new List() { symbol }; allDefines.AddRange(Symbols.Except(allDefines)); PlayerSettings.SetScriptingDefineSymbolsForGroup( EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", allDefines.ToArray())); } } }