目标:
给现有的宏定义添加新的宏定义。
#if UNITY_EDITOR //获取当前是哪个平台 BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; //获得当前平台已有的的宏定义 var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); //添加你想要的宏定义 if (!symbols.Contains("SARF")) { string str = ""; str = symbols + ";SARF"; PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, str); } #endif