public void ResetData()
        {
            DatabaseVariables database = IDatabase.LoadDatabaseCopy <DatabaseVariables>();

            this.references = database.GetGlobalVariables().references;
            this.RequireInit(true);
        }
        // OVERRIDERS: ----------------------------------------------------------------------------

        protected override GUIContent[] GetVariables(int allowTypesMask)
        {
            DatabaseVariables database = DatabaseVariables.Load();

            if (database == null || database.GetGlobalVariables() == null)
            {
                PreferencesWindow.OpenWindowTab("Variables");
                return(new GUIContent[0]);
            }

            GlobalVariables   globalVariables = database.GetGlobalVariables();
            List <GUIContent> variables       = new List <GUIContent>();

            for (int i = 0; i < globalVariables.references.Length; ++i)
            {
                Variable.DataType type = (Variable.DataType)globalVariables.references[i].variable.type;
                if ((allowTypesMask & 1 << (int)type) == 0)
                {
                    continue;
                }

                variables.Add(new GUIContent(
                                  " " + globalVariables.references[i].variable.name,
                                  VariableEditorUtils.GetIcon(type)
                                  ));
            }

            return(variables.ToArray());
        }
Beispiel #3
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private static void RequireGlobals()
        {
            if (REFERENCE != null)
            {
                return;
            }

            DatabaseVariables database = IDatabase.LoadDatabaseCopy <DatabaseVariables>();

            REFERENCE = database.GetGlobalVariables();
        }
        private void RequireInit(bool force = false)
        {
            if (this.variables != null && !force)
            {
                return;
            }

            if (!this.igamesaveInitialized)
            {
                SaveLoadManager.Instance.Initialize(this);
                this.igamesaveInitialized = true;
            }

            DatabaseVariables database        = IDatabase.LoadDatabaseCopy <DatabaseVariables>();
            GlobalVariables   globalVariables = database.GetGlobalVariables();

            this.variables = new Dictionary <string, Variable>();
            if (globalVariables == null)
            {
                return;
            }

            for (int i = 0; i < globalVariables.references.Length; ++i)
            {
                Variable variable = Instantiate(globalVariables.references[i]).variable;

                if (variable == null)
                {
                    continue;
                }
                string variableName = variable.name;

                if (!this.variables.ContainsKey(variableName))
                {
                    this.variables.Add(variableName, variable);
                }
            }
        }