Exemplo n.º 1
0
        private void ConfigureLostDefines()
        {
            List <Define> validDefines = new List <Define>
            {
                // Unity Packages Defines
                new Define("USING_UNITY_ADS", false),
                new Define("USING_UNITY_ANALYTICS", false),
                new Define("USING_UNITY_PURCHASING", false),
                new Define("USING_UNITY_ADDRESSABLES", false),
                new Define("USING_UNITY_AR_FOUNDATION", false),

                // Thrid Party Packages Defines
                new Define("USING_TIINOO", false),
                new Define("USING_PLAYFAB_SDK", false),
                new Define("USING_FACEBOOK_SDK", false),
                new Define("USING_ANDROID_FIREBASE_MESSAGING", false),
                new Define("USING_I2_LOCALIZATION", false),
                new Define("USING_LITE_NET_LIB", false),
            };

            // Adding all valid defines to our list of defines (if they don't already exist)
            HashSet <string> validDefineNames = new HashSet <string>();

            bool definesAdded = false;

            foreach (var define in validDefines)
            {
                validDefineNames.Add(define.Name);
                definesAdded |= this.AddLostDefine(define);
            }

            // If any defines were added, then sort them by name
            if (definesAdded)
            {
                this.defines = this.defines.OrderBy(x => x.Name).ToList();
            }

            // Determining if there are any old defines in our defines list that should be removed
            HashSet <string> invalidDefineNames = new HashSet <string>();

            foreach (var define in this.defines)
            {
                if (validDefineNames.Contains(define.Name) == false)
                {
                    invalidDefineNames.Add(define.Name);
                }
            }

            // Removing invalid defines from project settings and our defines list
            if (invalidDefineNames.Count > 0)
            {
                definesAdded = true;
                this.defines = this.defines.Where(x => invalidDefineNames.Contains(x.Name) == false).OrderBy(x => x.Name).ToList();
                EditorAppConfigDefinesHelper.UpdateProjectDefines(new HashSet <string>(), invalidDefineNames);
            }
        }
Exemplo n.º 2
0
        public override void InitializeOnLoad(Lost.AppConfig.AppConfig appConfig)
        {
            var lostDefineSettings = appConfig.GetSettings <LostDefineSettings>();

            HashSet <string> definesToAdd    = new HashSet <string>();
            HashSet <string> definesToRemove = new HashSet <string>();

            foreach (var define in lostDefineSettings.defines)
            {
                if (define.IsEnabled)
                {
                    definesToAdd.Add(define.Name);
                }
                else
                {
                    definesToRemove.Add(define.Name);
                }
            }

            EditorAppConfigDefinesHelper.UpdateProjectDefines(definesToAdd, definesToRemove);
        }