Beispiel #1
0
        // INITIALIZERS: --------------------------------------------------------------------------

        public override void OnOpen()
        {
            GlobalTags instance = AssetDatabase.LoadAssetAtPath <GlobalTags>(Path.Combine(
                                                                                 GlobalTagsEditor.PATH_ASSET,
                                                                                 GlobalTagsEditor.NAME_ASSET
                                                                                 ));

            if (instance == null)
            {
                this.editorWindow.Close();
            }
            this.tagsEditor = (GlobalTagsEditor)Editor.CreateEditor(instance);
        }
Beispiel #2
0
        // PUBLIC STATIC METHODS: -----------------------------------------------------------------

        public static Tag[] GetTags()
        {
            if (GLOBAL_TAGS_INSTANCE == null)
            {
                GLOBAL_TAGS_INSTANCE = AssetDatabase.LoadAssetAtPath <GlobalTags>(Path.Combine(
                                                                                      GlobalTagsEditor.PATH_ASSET,
                                                                                      GlobalTagsEditor.NAME_ASSET
                                                                                      ));
            }

            if (GLOBAL_TAGS_INSTANCE == null)
            {
                return(new Tag[0]);
            }
            return(GLOBAL_TAGS_INSTANCE.tags);
        }
        // INITIALIZE: ----------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }

            this.spTags = serializedObject.FindProperty(PROP_GLOBALTAGS);
            if (this.spTags.objectReferenceValue == null)
            {
                GameCreatorUtilities.CreateFolderStructure(GlobalTagsEditor.PATH_ASSET);
                GlobalTags instance = ScriptableObject.CreateInstance <GlobalTags>();
                AssetDatabase.CreateAsset(instance, Path.Combine(
                                              GlobalTagsEditor.PATH_ASSET,
                                              GlobalTagsEditor.NAME_ASSET
                                              ));

                this.spTags.objectReferenceValue = instance;
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();
            }

            this.spVariables = serializedObject.FindProperty(PROP_GLOBALVARIABLES);
            if (this.spVariables.objectReferenceValue == null)
            {
                GameCreatorUtilities.CreateFolderStructure(GlobalVariablesEditor.PATH_ASSET);
                GlobalVariables instance = ScriptableObject.CreateInstance <GlobalVariables>();
                AssetDatabase.CreateAsset(instance, Path.Combine(
                                              GlobalVariablesEditor.PATH_ASSET,
                                              GlobalVariablesEditor.NAME_ASSET
                                              ));

                this.spVariables.objectReferenceValue = instance;
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();
            }

            this.variablesEditor = (GlobalVariablesEditor)CreateEditor(
                this.spVariables.objectReferenceValue
                );
        }