예제 #1
0
 private static void CreateFolderStructure(GenericHierarchyConfig folderConfig)
 {
     foreach (var item in folderConfig.entries)
     {
         CreateFolder(item, "Assets");
     }
 }
예제 #2
0
        /// <summary>
        /// Given a path to a config, loads the folder config and returns it
        /// </summary>
        /// <param name="configPath"></param>
        /// <returns></returns>
        public static GenericHierarchyConfig LoadConfigFromPath(string configPath)
        {
            var folderConfig = new GenericHierarchyConfig();

            folderConfig = Core.LoadConfig(configPath);
            return(folderConfig);
        }
 /// <summary>
 /// given a config, generate a textarea to display the raw json
 /// </summary>
 /// <param name="config"></param>
 protected void ShowSceneConfigRaw(GenericHierarchyConfig config)
 {
     rawTemplateText  = Core.ConfigToString(config);
     _sceneEditScroll = GUILayout.BeginScrollView(_sceneEditScroll, GUILayout.Width(RIGHTPANELWIDTH), GUILayout.ExpandHeight(true));
     {
         rawTemplateText = GUILayout.TextArea(rawTemplateText, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
     }
     GUILayout.EndScrollView();
 }
 /// <summary>
 /// given a config, generate a textarea to display the raw json
 /// </summary>
 /// <param name="config"></param>
 protected void ShowFolderConfigRaw(GenericHierarchyConfig config)
 {
     rawTemplateText   = Core.ConfigToString(config);
     _folderEditScroll = GUILayout.BeginScrollView(_folderEditScroll, GUILayout.Width(350f), GUILayout.ExpandHeight(true));
     {
         rawTemplateText = GUILayout.TextArea(rawTemplateText, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
     }
     GUILayout.EndScrollView();
 }
예제 #5
0
        public static GenericHierarchyConfig LoadConfig(string configPath)
        {
            var newConfig = new GenericHierarchyConfig();

            if (File.Exists(configPath))
            {
                var sceneJson = File.ReadAllText(configPath);
                newConfig = JsonConvert.DeserializeObject <GenericHierarchyConfig>(sceneJson);
            }
            return(newConfig);
        }
예제 #6
0
 /// <summary>
 /// resets our selection completely
 /// </summary>
 public static void ClearSelection()
 {
     SetActiveConfigDirty(false);
     activeSelection             = null;
     activeEntrySelection        = null;
     activeConfig                = null;
     configNameDirty             = false;
     configDescriptionDirty      = false;
     tempConfigDescriptionString = string.Empty;
     tempConfigNameString        = string.Empty;
 }
예제 #7
0
        /// <summary>
        /// We've switched to a different config, let's reset and load that config
        /// </summary>
        /// <param name="newSelection"></param>
        public static void SetActiveSelection(TemplateButtonEntry newSelection)
        {
            ClearSelection();
            activeSelection = newSelection;
            // reset template file name for copies
            tempFileName = activeSelection.displayName + " Copy";

            // load the active config
            activeConfig = Core.LoadConfig(activeSelection.path);
            // cache these, they are used in the template editor
            tempConfigNameString        = activeConfig.name;
            tempConfigDescriptionString = activeConfig.description;
        }
예제 #8
0
        private void OnGUI()
        {
            GUILayout.Space(10f);
            titleContent = new GUIContent(Loc.DIALOG_NEWCONFIG_TITLE);
            GUILayout.Space(10f);

            GUILayout.Label(Loc.DIALOG_NEWCONFIG_MESSAGE, EditorStyles.helpBox);
            GUILayout.Space(10f);

            GUILayout.Label(Loc.DIALOG_NEWCONFIG_SELECTTYPE);
            selectedType = EditorGUILayout.Popup(selectedType, validTypes);
            GUILayout.Space(10f);

            switch (selectedType)
            {
            case (int)TEMPLATE_TYPE.FOLDER:
            {
                GUILayout.Label(Loc.DIALOG_NEWCONFIG_HELP_FOLDER, EditorStyles.helpBox);
                break;
            }

            case (int)TEMPLATE_TYPE.SCENE:
            {
                GUILayout.Label(Loc.DIALOG_NEWCONFIG_HELP_SCENE, EditorStyles.helpBox);
                break;
            }
            }

            GUILayout.Space(10f);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(Loc.DIALOG_NEWCONFIG_FILENAME, GUILayout.Width(LABEL_WIDTH));
                // show our text input and make sure that it's focused
                GUI.SetNextControlName("textInput");
                templateFileName = GUILayout.TextField(templateFileName, GUILayout.ExpandWidth(true));
                if (!focused)
                {
                    GUI.FocusControl("textInput");
                    var te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                    te.cursorIndex = 1;
                    focused        = true;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(Loc.DIALOG_NEWCONFIG_DISPLAYNAME, GUILayout.Width(LABEL_WIDTH));
                templateDisplayName = GUILayout.TextField(templateDisplayName, GUILayout.ExpandWidth(true));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            {
                var style = EditorStyles.miniButton;

                GUI.backgroundColor = Loc.cancelColor;
                if (GUILayout.Button("Cancel", style, GUILayout.Height(35f)))
                {
                    Close();
                }

                GUI.backgroundColor = Loc.doneColor;
                if (GUILayout.Button("Save", style, GUILayout.Height(35f)))
                {
                    if (templateFileName != string.Empty)
                    {
                        switch (selectedType)
                        {
                        case (int)TEMPLATE_TYPE.FOLDER:
                        {
                            var newFolderConfig = new GenericHierarchyConfig()
                            {
                                name = templateDisplayName,
                                type = TEMPLATE_TYPE.FOLDER
                            };
                            // save the new config into the user's templates folder
                            Core.SaveConfig(templateFileName, newFolderConfig);

                            Control.Reset();
                            break;
                        }

                        case (int)TEMPLATE_TYPE.SCENE:
                        {
                            var newSceneConfig = new GenericHierarchyConfig()
                            {
                                name = templateDisplayName,
                                type = TEMPLATE_TYPE.SCENE
                            };
                            // save the new config into the user's templates folder
                            Core.SaveConfig(templateFileName, newSceneConfig);

                            Control.Reset();

                            // attempt to reset the parent window so we can refresh our file list, but doesn't seem to work, unity asset database doesn't refresh in time
                            if (opener.windowType == EditorWindowType.NewSceneWizard)
                            {
                                var parentWindow = (NewSceneWizardView)opener;
                                parentWindow.Reset();
                            }
                            else if (opener.windowType == EditorWindowType.TemplateEditor)
                            {
                                var parentWindow = (TemplateEditorView)opener;
                                parentWindow.Reset();
                            }

                            break;
                        }
                        }
                        Close();
                    }
                }
                GUI.backgroundColor = Loc.defaultColor;
            }
            GUILayout.EndHorizontal();
        }
예제 #9
0
        public static void SaveConfig(string newFileName, GenericHierarchyConfig config)
        {
            var configTxt = ConfigToString(config);

            WriteConfigToDisk(configTxt, newFileName);
        }
예제 #10
0
 public static string ConfigToString(GenericHierarchyConfig config)
 {
     return(JsonConvert.SerializeObject(config, Formatting.Indented));
 }