两个函数PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup); //所有宏定义 ; 分割
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, sz); //写入全部宏,相当于改配置
使用笔记需要考虑一组宏定义的互斥问题,要保持不改动的宏不变,示例代码如下
public static void SetDebugerLevle(string logType)
{
BuildTargetGroup targetGroup = BuildTargetGroup.Android;
string ori = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
string debugType = "Debuger_" + logType;
List<string> defineSymbols = new List<string>(ori.Split(';'));
for (int i = 0; i < defineSymbols.Count; ++i)
{
if (defineSymbols[i] == debugType)
{
Debug.LogFormat("========== debuglog {0}", logType);
return;
}
if (defineSymbols[i].StartsWith("Debuger_"))
{
defineSymbols[i] = debugType;
debugType = null;
break;
}
}
if (debugType != null)
{
defineSymbols.Add(debugType);
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", defineSymbols.ToArray()));
Debug.LogFormat("========== debuglog {0}", logType);
}
PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup); //所有宏定义 ; 分割
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, sz); //写入全部宏,相当于改配置
需要考虑一组宏定义的互斥问题,要保持不改动的宏不变,示例代码如下
public static void SetDebugerLevle(string logType)
{
BuildTargetGroup targetGroup = BuildTargetGroup.Android;
string ori = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
string debugType = "Debuger_" + logType;
List<string> defineSymbols = new List<string>(ori.Split(';'));
for (int i = 0; i < defineSymbols.Count; ++i)
{
if (defineSymbols[i] == debugType)
{
Debug.LogFormat("========== debuglog {0}", logType);
return;
}
if (defineSymbols[i].StartsWith("Debuger_"))
{
defineSymbols[i] = debugType;
debugType = null;
break;
}
}
if (debugType != null)
{
defineSymbols.Add(debugType);
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", defineSymbols.ToArray()));
Debug.LogFormat("========== debuglog {0}", logType);
}