public static void ManageScriptingDefineSymbols()
        {
            BuildTargetGroup[] targetGroups = ApplicationTool.GetValidBuildTargetGroups();
            Dictionary <BuildTargetGroup, HashSet <string> > newSymbolsByTargetGroup = new Dictionary <BuildTargetGroup, HashSet <string> >(targetGroups.Length);

            //获取新的Symbols
            foreach (ScriptingDefineSymbolPredicateInfo predicateInfo in AvailableScriptingDefineSymbolPredicateInfos)
            {
                AFSDK_ScriptingDefineSymbolAttribute predicateAttribute = predicateInfo.attribute;
                string     symbol     = predicateAttribute.SDKSymbol;
                MethodInfo methodInfo = predicateInfo.methodInfo;
                if (!(bool)methodInfo.Invoke(null, null))
                {
                    continue;
                }
                AFSDK_ScriptingDefineSymbolAttribute[] allAttributes = (AFSDK_ScriptingDefineSymbolAttribute[])methodInfo.GetCustomAttributes(typeof(AFSDK_ScriptingDefineSymbolAttribute), false);
                foreach (AFSDK_ScriptingDefineSymbolAttribute attribute in allAttributes)
                {
                    BuildTargetGroup buildTargetGroup = attribute.buildTargetGroup;
                    HashSet <string> newSymbols;
                    if (!newSymbolsByTargetGroup.TryGetValue(buildTargetGroup, out newSymbols))
                    {
                        newSymbols = new HashSet <string>();
                        newSymbolsByTargetGroup[buildTargetGroup] = newSymbols;
                    }
                    newSymbols.Add(attribute.SDKSymbol);
                }
            }
            if (newSymbolsByTargetGroup.Count == 0)
            {
                foreach (BuildTargetGroup targetGroup in ApplicationTool.GetValidBuildTargetGroups())
                {
                    string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                              .Split(';')
                                              .Distinct()
                                              .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                              .Where(symbol => !symbol.StartsWith(AFSDK_ScriptingDefineSymbolAttribute.SymbolPrefix, StringComparison.Ordinal))
                                              .ToArray();
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", currentSymbols));
                }
                return;
            }
            foreach (KeyValuePair <BuildTargetGroup, HashSet <string> > keyValuePair in newSymbolsByTargetGroup)
            {
                BuildTargetGroup targetGroup = keyValuePair.Key;
                if (targetGroup == BuildTargetGroup.Unknown)
                {
                    continue;
                }

                string[] newSymbols     = keyValuePair.Value.OrderBy(symbol => symbol, StringComparer.Ordinal).ToArray();
                string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                          .Split(';')
                                          .Distinct()
                                          .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                          .ToArray();
                string[] ARSDKSystem = currentSymbols.Where(symbol => symbol.StartsWith(AFSDK_ScriptingDefineSymbolAttribute.SymbolPrefix, StringComparison.Ordinal)).ToArray();
                if (ARSDKSystem.SequenceEqual(newSymbols))
                {
                    continue;
                }
                AFLogger.d("ARSDK有变化");

                string[] finallySymbol = newSymbols.Concat(currentSymbols.Where(symbol => !symbol.StartsWith(AFSDK_ScriptingDefineSymbolAttribute.SymbolPrefix, StringComparison.Ordinal)).ToArray()).ToArray();
                PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", finallySymbol));
            }
        }
Exemple #2
0
 public AFSDK_ScriptingDefineSymbolAttribute(AFSDK_ScriptingDefineSymbolAttribute attributeToCopy)
 {
     SDKSymbol = attributeToCopy.SDKSymbol;
     SetBuildTarget(attributeToCopy.buildTargetGroupName);
 }
 public ScriptingDefineSymbolPredicateInfo(AFSDK_ScriptingDefineSymbolAttribute attribute, MethodInfo methodInfo)
 {
     this.attribute  = attribute;
     this.methodInfo = methodInfo;
 }