using System.Collections.Generic; using UnityEditor; namespace Ubisoft { public class HtPlayerSettings { private const char DEFINE_SYMBOLS_SEPARATOR = ';'; public const string HT_PLUGGABLE_SYMBOLS_BEGIN = "HT_PLUGGABLE_SYMBOLS_BEGIN"; public const string HT_PLUGGABLE_SYMBOLS_END = "HT_PLUGGABLE_SYMBOLS_END"; public static string SymbolsToStr(HashSet symbols) { string returnValue = ""; if (symbols != null) { string thisValue; int count = 0; foreach (string value in symbols) { thisValue = value?.Trim(); if (!string.IsNullOrEmpty(thisValue)) { if (count > 0) { returnValue += DEFINE_SYMBOLS_SEPARATOR; } returnValue += thisValue; count++; } } } return returnValue; } /// /// Retrieve the list of define symbols for the build target groupd passed in. /// /// Build target group to retrieve the list of define symbols for. /// Whether or not pluggable define symbols, the one defined by Hotel and the consumer depending on the suite to apply, /// need to be stripped. /// public static HashSet GetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTargetGroup, bool trimPluggableSymbols = false, bool trimNonPluggableSymbols = false) { HashSet returnValue = new HashSet(); bool isPluggableSymbol = false; string symbolsAsStr = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); string[] symbols = symbolsAsStr.Split(DEFINE_SYMBOLS_SEPARATOR); foreach (string symbol in symbols) { if (symbol.Equals(HT_PLUGGABLE_SYMBOLS_BEGIN)) { isPluggableSymbol = true; } bool addSymbol = !string.IsNullOrEmpty(symbol); if (addSymbol) { if ((trimNonPluggableSymbols && !isPluggableSymbol) || (trimPluggableSymbols && isPluggableSymbol)) { addSymbol = false; } } if (addSymbol) { _ = returnValue.Add(symbol); } if (isPluggableSymbol && symbol.Equals(HT_PLUGGABLE_SYMBOLS_END)) { isPluggableSymbol = false; } } return returnValue; } public static void SetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTargetGroup, string value) { string symbolsAsStr = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); if (!symbolsAsStr.Equals(value)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, value); } } public static void SetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTargetGroup, HashSet value) { SetScriptingDefineSymbolsForGroup(buildTargetGroup, SymbolsToStr(value)); } } }