/// <summary>
        /// Adds our '+ / -' new entry / remove entry edit buttons after an entry. If entry is null, we're adding a top-level element
        /// </summary>
        /// <param name="entry"></param>
        protected void CreateEntryEditControls(GenericHierarchyEntry entry)
        {
            // show our add / remove buttons for each entry (to add a child or remove the current entry)
            GUI.backgroundColor = Loc.doneColor;
            var add = new GUIContent(imgAdd, Loc.TOOLTIP_ADDCHILDELEMENT);

            if (GUILayout.Button(add, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
            {
                Control.ShowNewFolderEntryDialog(entry);
            }
            GUI.backgroundColor = Loc.cancelColor;
            var remove = new GUIContent(imgRemove, Loc.TOOLTIP_REMOVEELEMENT);

            if (GUILayout.Button(remove, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
            {
                var entryMessage = Loc.DIALOG_CONFIRMDELETEENTRY_MESSAGE + " : " + entry.name;
                if (EditorUtility.DisplayDialog(Loc.DIALOG_CONFIRMDELETE_TITLE,
                                                entryMessage,
                                                Loc.DIALOG_OK,
                                                Loc.DIALOG_CANCEL))
                {
                    Control.FindAndRemoveConfigEntry(entry);
                }
            }
            GUI.backgroundColor = Loc.defaultColor;
        }
 public new void Reset()
 {
     Control.Reset();
     // preload the configs
     base.Reset();
     editWindowInt = 0;
 }
 public new void Reset()
 {
     // default to scene unless we get told otherwise
     filterType = TEMPLATE_TYPE.SCENE;
     windowType = EditorWindowType.NewSceneWizard;
     Control.Reset();
     base.Reset();
 }
Exemple #4
0
 public static void ConfigureProject()
 {
     if (EditorUtility.DisplayDialog(Loc.DIALOG_NEWPROJECTSETUP_TITLE,
                                     Loc.DIALOG_NEWPROJECTSETUP_MESSSAGE,
                                     Loc.DIALOG_OK,
                                     Loc.DIALOG_CANCEL))
     {
         Control.ConfigureProject();
     }
 }
        protected void Reset()
        {
            // reset the controller
            Control.Reset();

            _folderEditScroll = Vector2.zero;
            _sceneEditScroll  = Vector2.zero;
            _templateScroll   = Vector2.zero;
            _sceneViewScroll  = Vector2.zero;

            /*
             * Generate our template buttons
             */

            // templates built into the package
            Control.defaultTemplateButtons.Clear();
            foreach (var template in Core.defaultTemplates)
            {
                // load the config
                var config = Core.LoadGenericConfig(template.path);
                var button = new TemplateButtonEntry
                {
                    config      = config,
                    displayName = config.name,
                    fileName    = template.fileName,
                    description = config.description,
                    path        = template.path,
                    type        = config.type,
                    isPressed   = false,
                    isBuiltIn   = true,
                };
                Control.defaultTemplateButtons.Add(button);
            }

            // templates in user-land project space
            Control.userTemplateButtons.Clear();
            foreach (var template in Core.userTemplates)
            {
                var config = Core.LoadGenericConfig(template.path);
                var button = new TemplateButtonEntry
                {
                    config      = config,
                    displayName = config.name,
                    fileName    = template.fileName,
                    description = config.description,
                    path        = template.path,
                    type        = config.type,
                    isPressed   = false,
                    isBuiltIn   = false,
                };
                Control.userTemplateButtons.Add(button);
            }
        }
        /// <summary>
        /// Helper to generate controls in our list
        /// </summary>
        /// <param name="button"></param>
        protected void CreateTemplateButton(TemplateButtonEntry button)
        {
            var shortName  = button.displayName.Split('.')[0];
            var configPath = button.path;
            var config     = button.config;
            var type       = button.type;

            button.isPressed = GUILayout.Toggle(button.isPressed, new GUIContent(shortName, null, Loc.TOOLTIP_TEMPLATELIST_OPTIONS), "Button", GUILayout.MaxWidth(STANDARDBUTTONSIZE), GUILayout.MaxHeight(STANDARDBUTTONHEIGHT));
            if (button.isPressed)
            {
                var actuallySwitch = Control.ConfirmSwitchActiveButton(button);
                if (!actuallySwitch)
                {
                    button.isPressed = false;
                }
                else
                {
                    button.isPressed = true;
                }
            }
        }
        /// <summary>
        /// Duplicate selected config UI
        /// </summary>
        protected void ShowDuplicateConfigUI()
        {
            GUILayout.Space(10f);
            GUILayout.Label(Loc.DUPE_TITLE, EditorStyles.boldLabel, GUILayout.MaxWidth(RIGHTPANELWIDTH));
            GUILayout.Label(Loc.DUPE_HELPTEXT, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
            GUILayout.Space(10f);

            GUILayout.Label(Loc.DUPE_DESTNAME, GUILayout.MaxWidth(RIGHTPANELWIDTH));

            Control.tempFileName = GUILayout.TextField(Control.tempFileName, GUILayout.MaxWidth(RIGHTPANELWIDTH));
            GUILayout.Label(Loc.DUPE_LOCATION, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
            GUILayout.Space(10f);

            GUI.backgroundColor = Loc.doneColor;
            if (GUILayout.Button("Duplicate", GUILayout.MaxWidth(RIGHTPANELWIDTH), GUILayout.MaxHeight(STANDARDBUTTONHEIGHT)))
            {
                // duplicate our active selection
                Control.DuplicateConfig(Control.tempFileName);
                Reset();
            }
            GUI.backgroundColor = Loc.defaultColor;
        }
        private void OnGUI()
        {
            GUILayout.Space(10f);
            titleContent = new GUIContent(dialogTitle);
            GUILayout.Label(dialogMessage, EditorStyles.helpBox);

            GUILayout.Space(10f);
            // show our text input and make sure that it's focused
            GUI.SetNextControlName("textInput");
            inputValue = GUILayout.TextField(inputValue, GUILayout.ExpandWidth(true));
            if (!focused)
            {
                GUI.FocusControl("textInput");
                var te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                te.cursorIndex = 1;
                focused        = true;
            }

            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 (inputValue != string.Empty)
                    {
                        if (entry != null)
                        {
                            Debug.Log("Adding new Entry: " + inputValue + " to parent : " + entry.name);
                        }
                        else
                        {
                            Debug.Log("Add new Top-Level Entry: " + inputValue);
                        }

                        switch (dialogType)
                        {
                        case DialogType.NewEntryName:
                        {
                            Control.entryEditDirty = true;
                            Control.AddFolderEntry(entry, inputValue);
                            break;
                        }

                        default:
                        {
                            Debug.Log("Unknown dialog type?");
                            break;
                        }
                        }

                        Close();
                    }
                }

                GUI.backgroundColor = Loc.defaultColor;
            }
            GUILayout.EndHorizontal();
        }
        private void OnGUI()
        {
            curWindowSize.x = position.width;
            curWindowSize.y = position.height;

            GUILayout.BeginHorizontal(GUILayout.MinWidth(minWindowSize.x), GUILayout.MinHeight(minWindowSize.y));
            {
                GUILayout.BeginVertical();
                {
                    DrawBanner(CONTENTWINDOW.NEWCONTENTWIZARD);

                    GUILayout.BeginHorizontal();
                    {
                        // generate our left column, show only scene templates
                        GenerateTemplateListView(CONTENTWINDOW.NEWCONTENTWIZARD, filterType, false);

                        GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                        {
                            GUILayout.Space(10f);

                            if (Control.activeConfig != null)
                            {
                                GUILayout.Label("Selection : " + Control.activeConfig.type);
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label("Name: ", EditorStyles.boldLabel, GUILayout.MaxWidth(150f));
                                    GUILayout.Label(Control.activeConfig.name, EditorStyles.boldLabel, GUILayout.MaxWidth(150f));
                                }
                                GUILayout.EndHorizontal();

                                GUILayout.TextArea("Description: " + Control.activeConfig.description, GUILayout.MaxWidth(350f), GUILayout.Height(60f));

                                GUILayout.Space(10f);

                                ViewTemplate(false);

                                GUILayout.Space(10f);

                                var buttonInfo = new GUIContent();
                                switch (filterType)
                                {
                                case TEMPLATE_TYPE.SCENE:
                                {
                                    buttonInfo = new GUIContent(Loc.NEWCONTENT_GENERATESCENE, null, Loc.TOOLTIP_NEWCONTENT_GENERATESCENE);
                                    break;
                                }

                                case TEMPLATE_TYPE.FOLDER:
                                {
                                    buttonInfo = new GUIContent(Loc.NEWCONTENT_GENERATEFOLDER, null, Loc.TOOLTIP_NEWCONTENT_GENERATEFOLDERS);
                                    break;
                                }
                                }

                                GUI.backgroundColor = Loc.doneColor;
                                if (GUILayout.Button(buttonInfo, GUILayout.MaxWidth(STANDARDBUTTONSIZE), GUILayout.MaxHeight(STANDARDBUTTONHEIGHT)))
                                {
                                    var dialogTitle = string.Empty;
                                    var dialogInfo  = string.Empty;
                                    switch (filterType)
                                    {
                                    case TEMPLATE_TYPE.SCENE:
                                    {
                                        dialogTitle = Loc.DIALOG_POPSCENE_TITLE;
                                        dialogInfo  = Loc.DIALOG_POPSCENE_MESSSAGE;
                                        break;
                                    }

                                    case TEMPLATE_TYPE.FOLDER:
                                    {
                                        dialogTitle = Loc.DIALOG_POPFOLDER_TITLE;
                                        dialogInfo  = Loc.DIALOG_POPFOLDER_MESSSAGE;
                                        break;
                                    }
                                    }
                                    if (EditorUtility.DisplayDialog(dialogTitle,
                                                                    dialogInfo,
                                                                    Loc.DIALOG_OK,
                                                                    Loc.DIALOG_CANCEL))
                                    {
                                        switch (filterType)
                                        {
                                        case TEMPLATE_TYPE.FOLDER:
                                        {
                                            Control.PopulateFolderStructure(Control.activeSelection.path);
                                            this.Close();
                                            break;
                                        }

                                        case TEMPLATE_TYPE.SCENE:
                                        {
                                            Control.PopulateSceneStructure(Control.activeSelection.path);
                                            this.Close();
                                            break;
                                        }
                                        }
                                    }
                                }
                                GUI.backgroundColor = Loc.defaultColor;
                                GUILayout.Space(10f);
                            }
                            else
                            {
                                GUILayout.Space(10f);

                                GUILayout.Label(Loc.NCW_DEFAULTTEXT, EditorStyles.helpBox, GUILayout.MaxWidth(350f));
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
Exemple #10
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();
        }
        private void OnGUI()
        {
            curWindowSize.x = position.width;
            curWindowSize.y = position.height;

            GUILayout.BeginHorizontal(GUILayout.MinWidth(minWindowSize.x), GUILayout.MinHeight(minWindowSize.y));
            {
                GUILayout.BeginVertical();
                {
                    DrawBanner(CONTENTWINDOW.TEMPLATEEDITOR);

                    GUILayout.BeginHorizontal();
                    {
                        /*
                         *
                         * generate our left column, show all templates
                         *
                         *
                         */
                        GenerateTemplateListView(CONTENTWINDOW.TEMPLATEEDITOR, TEMPLATE_TYPE.ALL, true);

                        /*
                         *
                         * right column, active selection
                         *
                         */
                        GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                        {
                            GUILayout.Space(10f);

                            // if we have a selected, then show the template
                            if (Control.activeSelection != null)
                            {
                                // whether we're in read only mode or not
                                canEdit = !Control.activeSelection.isBuiltIn;

                                // name
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(Loc.EDIT_NAME, GUILayout.Width(50f));

                                    if (canEdit)
                                    {
                                        // monitor the text field for changes
                                        EditorGUI.BeginChangeCheck();
                                        {
                                            Control.tempConfigNameString = GUILayout.TextArea(Control.tempConfigNameString, GUILayout.Width(350f));
                                        }
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            Control.configNameDirty = true;
                                        }

                                        if (Control.configNameDirty)
                                        {
                                            // done button
                                            GUI.backgroundColor = Loc.doneColor;
                                            if (GUILayout.Button(imgDone, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                Debug.Log("save changes...");
                                                Control.SaveChangeToConfigName();
                                            }
                                            // cancel button
                                            GUI.backgroundColor = Loc.cancelColor;
                                            if (GUILayout.Button(imgCancel, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                // reset to what it was originally
                                                Control.tempConfigNameString = Control.activeConfig.name;
                                            }
                                            // reset colors back to default
                                            GUI.backgroundColor = Loc.defaultColor;
                                        }
                                    }
                                    else
                                    {
                                        GUILayout.TextArea(Control.activeConfig.name, GUILayout.Width(350f));
                                    }
                                }
                                GUILayout.EndHorizontal();

                                GUILayout.Label(Loc.EDIT_TEMPLATETYPE + Control.activeConfig.type);

                                // Description
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(Loc.EDIT_DESCRIPTION, GUILayout.Width(50f));
                                    if (canEdit)
                                    {
                                        // monitor the text field for changes
                                        EditorGUI.BeginChangeCheck();
                                        {
                                            Control.tempConfigDescriptionString = GUILayout.TextArea(Control.tempConfigDescriptionString, GUILayout.Width(350f), GUILayout.Height(100f));
                                        }
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            Control.configDescriptionDirty = true;
                                        }

                                        if (Control.configDescriptionDirty)
                                        {
                                            // done button
                                            GUI.backgroundColor = Loc.doneColor;
                                            if (GUILayout.Button(imgDone, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                Control.SaveChangeToConfigDescription();
                                            }
                                            // cancel button
                                            GUI.backgroundColor = Loc.cancelColor;
                                            if (GUILayout.Button(imgCancel, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                // reset to what it was originally
                                                Control.tempConfigDescriptionString = Control.activeConfig.description;
                                            }
                                            // reset colors back to default
                                            GUI.backgroundColor = Loc.defaultColor;
                                        }
                                    }
                                    else
                                    {
                                        GUILayout.TextArea(Control.activeConfig.description, GUILayout.Width(350f), GUILayout.Height(100f));
                                    }
                                }
                                GUILayout.EndHorizontal();

                                GUILayout.Label(Loc.EDIT_SOURCEFILE);
                                GUILayout.Label(Control.activeSelection.path, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));

                                /*
                                 * show our action toolbar
                                 */
                                editWindowInt = GUILayout.Toolbar(editWindowInt, Loc.EDITBUTTONS, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                                {
                                    switch (editWindowInt)
                                    {
                                    case (int)TOOLBAR_BUTTON.Edit:
                                    {
                                        GUILayout.Space(10f);
                                        GUILayout.Label(Loc.EDIT_TITLE, EditorStyles.boldLabel, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                                        GUILayout.Label(Loc.EDIT_HELPTEXT, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));

                                        GUILayout.Space(10f);

                                        // left column
                                        GUILayout.BeginHorizontal();
                                        {
                                            /*
                                             *
                                             * if it isn't a built in template, we can edit, otherwise read only
                                             * Display the Tree view
                                             *
                                             */
                                            ViewTemplate(canEdit);
                                        }
                                        GUILayout.EndHorizontal();

                                        break;
                                    }

                                    case (int)TOOLBAR_BUTTON.Raw:
                                    {
                                        GUILayout.Space(10f);
                                        GUILayout.Label(Loc.RAW_TITLE, EditorStyles.boldLabel, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                                        GUILayout.Label(Loc.RAW_HELPTEXT, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));

                                        GUILayout.Space(10f);

                                        ShowFolderConfigRaw(Control.activeConfig);
                                        break;
                                    }

                                    case (int)TOOLBAR_BUTTON.Delete:
                                    {
                                        ShowDeleteConfigUI();
                                        break;
                                    }

                                    case (int)TOOLBAR_BUTTON.Duplicate:
                                    {
                                        ShowDuplicateConfigUI();
                                        break;
                                    }
                                    }
                                }
                            }
                            else
                            {
                                GUILayout.Space(10f);

                                GUILayout.Label(Loc.RC_DEFAULTTEXT, EditorStyles.helpBox, GUILayout.MaxWidth(350f));
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
        /// <summary>
        /// Draw our left side 'template list' view with an optional filter for the type of template to show
        /// </summary>
        /// <param name="filter">Only show TEMPLATE_TYPE templates in the list</param>
        protected void GenerateTemplateListView(CONTENTWINDOW windowType, TEMPLATE_TYPE filter, bool canEdit)
        {
            GUILayout.BeginVertical(GUILayout.MaxWidth(LEFTCOLUMNSIZE), GUILayout.MinWidth(LEFTCOLUMNSIZE));
            {
                GUILayout.Space(10f);
                GUILayout.Label(Loc.TEMPLATELIST, EditorStyles.boldLabel);

                var scrollHeight = curWindowSize.y - 115;
                if (canEdit)
                {
                    scrollHeight = curWindowSize.y - 165;
                }
                _templateScroll = EditorGUILayout.BeginScrollView(_templateScroll, false, true,
                                                                  GUILayout.MinWidth(LEFTCOLUMNSIZE),
                                                                  GUILayout.MaxWidth(LEFTCOLUMNSIZE - 50),
                                                                  GUILayout.MinHeight(scrollHeight));
                {
                    GUILayout.Space(10f);

                    /*
                     *  Our default templates
                     */
                    GUILayout.Label(Loc.BUILTINTEMPLATES, EditorStyles.centeredGreyMiniLabel);
                    GUILayout.Space(10f);
                    foreach (var button in Control.defaultTemplateButtons)
                    {
                        if (filter != TEMPLATE_TYPE.ALL)
                        {
                            // if it's a match, draw it
                            if (button.type == filter)
                            {
                                CreateTemplateButton(button);
                            }
                        }
                        else
                        {
                            CreateTemplateButton(button);
                        }
                    }
                    GUILayout.Space(10f);

                    /*
                     *  Any available user templates in the project
                     */
                    GUILayout.Label(Loc.USERTEMPLATES, EditorStyles.centeredGreyMiniLabel);
                    GUILayout.Space(10f);
                    foreach (var button in Control.userTemplateButtons)
                    {
                        if (filter != TEMPLATE_TYPE.ALL)
                        {
                            if (button.type == filter)
                            {
                                CreateTemplateButton(button);
                            }
                        }
                        else
                        {
                            CreateTemplateButton(button);
                        }
                    }
                    GUILayout.Space(10f);
                }
                GUILayout.EndScrollView();
                GUILayout.Space(10f);

                if (canEdit)
                {
                    // our bottom buttons (below the template list) - users can add a new template or refresh the list (in case they edited / updated them outside of Unity)
                    GUILayout.BeginHorizontal();
                    {
                        var buttonWidth = 115f;

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

                        var add = new GUIContent(Loc.ADD, null, Loc.TOOLTIP_ADDTEMPLATE);
                        if (GUILayout.Button(add, style, GUILayout.Width(buttonWidth), GUILayout.Height(STANDARDBUTTONHEIGHT)))
                        {
                            // if the user has changed the current config at all, we need to verify what they want us to do before refreshing the template liste
                            if (Control.activeConfigEditDirty)
                            {
                                var action = EditorUtility.DisplayDialogComplex(Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_TITLE,
                                                                                Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_MESSAGE,
                                                                                Loc.DIALOG_YES,
                                                                                Loc.DIALOG_NO,
                                                                                Loc.DIALOG_CANCEL);
                                switch (action)
                                {
                                // save
                                case 0:
                                {
                                    Control.SaveConfigChanges();                // save changes
                                    Control.CreateNewConfig(this);              // create new config
                                    break;
                                }

                                // don't save
                                case 1:
                                {
                                    Reset();                                    // undo changes
                                    Control.CreateNewConfig(this);              // create new config
                                    break;
                                }

                                // cancel
                                case 2:
                                {
                                    break;
                                }
                                }
                            }
                            else
                            {
                                Control.CreateNewConfig(this);
                            }
                        }

                        // refresh the template list
                        var refresh = new GUIContent(Loc.REFRESH, null, Loc.TOOLTIP_REFRESHTEMPLATE);
                        if (GUILayout.Button(refresh, style, GUILayout.Width(buttonWidth), GUILayout.Height(STANDARDBUTTONHEIGHT)))
                        {
                            // if the user has changed the current config at all, we need to verify what they want us to do before refreshing the template liste
                            if (Control.activeConfigEditDirty)
                            {
                                var action = EditorUtility.DisplayDialogComplex(Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_TITLE,
                                                                                Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_MESSAGE,
                                                                                Loc.DIALOG_YES,
                                                                                Loc.DIALOG_NO,
                                                                                Loc.DIALOG_CANCEL);
                                switch (action)
                                {
                                // save
                                case 0:
                                {
                                    Debug.Log("FIXME: Save changes before refresh");
                                    break;
                                }

                                // don't save
                                case 1:
                                {
                                    Debug.Log("Discard Changes, refresh template list");
                                    Reset();
                                    break;
                                }

                                // cancel
                                case 2:
                                {
                                    Debug.Log("Cancel, don't refresh");
                                    break;
                                }
                                }
                            }
                            else
                            {
                                Reset();
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();
        }
        /// <summary>
        /// Generates the component editor for an individual entry - pick component, configure etc
        /// </summary>
        /// <param name="entry"></param>
        protected void CreateComponentEditor(GenericHierarchyEntry entry, bool canEdit)
        {
            switch (Control.activeConfig.type)
            {
            case TEMPLATE_TYPE.SCENE:
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Space(10f);
                    if (entry.components.Count > 0)
                    {
                        GUILayout.Label("Component List:");
                    }

                    for (var i = 0; i < entry.components.Count; i++)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Type:", GUILayout.MaxWidth(50f));
                            var componentType = entry.components[i].type.ToString();
                            GUILayout.Label(componentType, EditorStyles.helpBox, GUILayout.MaxWidth(150f));

                            if (canEdit)
                            {
                                GUILayout.Space(SMALLBUTTONSIZE + 5);

                                GUI.backgroundColor = Loc.cancelColor;
                                var remove = new GUIContent(imgRemove, Loc.TOOLTIP_REMOVEELEMENT);
                                if (GUILayout.Button(remove, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                {
                                    var confirmDeleteComponentMessage = new StringBuilder();
                                    confirmDeleteComponentMessage.Append(Loc.DIALOG_CONFIRMDELETECOMPONENT_MESSAGE);
                                    confirmDeleteComponentMessage.Append(componentType);
                                    confirmDeleteComponentMessage.Append(" from entry: ");
                                    confirmDeleteComponentMessage.Append(entry.name);

                                    if (EditorUtility.DisplayDialog(Loc.DIALOG_CONFIRMDELETE_TITLE,
                                                                    confirmDeleteComponentMessage.ToString(),
                                                                    Loc.DIALOG_OK,
                                                                    Loc.DIALOG_CANCEL))
                                    {
                                        Control.RemoveComponentFromEntry(entry, entry.components[i].type);
                                        break;
                                    }
                                }
                                GUI.backgroundColor = Loc.defaultColor;
                            }
                        }
                        GUILayout.EndHorizontal();

                        if (canEdit)
                        {
                            if (Control.DoesComponentRequireSubassets(entry.components[i].type))
                            {
                                Control.entryCreateSubAsset = EditorGUILayout.Toggle("Create Sub-Asset?", Control.entryCreateSubAsset);
                                if (Control.entryCreateSubAsset)
                                {
                                    GUILayout.Label("Select template for sub asset");
                                }
                            }
                        }
                    }

                    if (canEdit)
                    {
                        GUILayout.Space(10f);

                        GUILayout.Label("Add new Component:", GUILayout.MaxWidth(STANDARDBUTTONSIZE));

                        // dropdown of supported component types
                        Control.entrySelectedComponent = EditorGUILayout.Popup(Control.entrySelectedComponent, Control.componentsForEntry.ToArray(), GUILayout.MaxWidth(STANDARDBUTTONSIZE));
                        if (Control.entrySelectedComponent > 0)
                        {
                            GUI.backgroundColor = Loc.doneColor;
                            if (GUILayout.Button("[ Add ]", GUILayout.MaxWidth(STANDARDBUTTONSIZE)))
                            {
                                // figure out what type this is, and add it to the list
                                var type = Enum.Parse(typeof(COMPONENT_TYPE), Control.componentsForEntry[Control.entrySelectedComponent]);

                                Control.AddComponentToEntry(entry, (COMPONENT_TYPE)type);
                            }
                            GUI.backgroundColor = Loc.defaultColor;
                        }
                    }
                }
                GUILayout.EndVertical();
                break;
            }
            }
        }
        /// <summary>
        /// Recursively generate the UI required to display the treeview structure that the template will generate
        /// </summary>
        /// <param name="entry">This entry</param>
        /// <param name="parent">name of the parent (if any)</param>
        /// <param name="canEdit">whether we are in edit mode or just view</param>
        /// /// <param name="offset">Horizontal offset for the entry</param>
        protected void CreateTreeViewUI(GenericHierarchyEntry entry, string parent, bool canEdit, float offset)
        {
            var hasChildren = false;

            if (entry.children != null)
            {
                if (entry.children.Count > 0)
                {
                    hasChildren = true;
                }
            }
            if (parent != string.Empty)
            {
                offset += HIERARCHYINDENTOFFSET;
            }

            // draw the entry
            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(offset); // indent
                if (hasChildren)
                {
                    GUILayout.Label(imgArrowDown, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE));
                }
                else
                {
                    GUILayout.Label(imgArrowRight, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE));
                }

                // draw the list entry like a label, but it's actually a button, make it bold if we are in edit mode & selected
                var style = EditorStyles.label;
                if (canEdit)
                {
                    // if we're selected, make us bold
                    if (Control.activeEntrySelection == entry)
                    {
                        style = EditorStyles.boldLabel;
                    }
                }

                if (GUILayout.Button(entry.name, style, GUILayout.ExpandWidth(true)))
                {
                    Control.SetActiveEntrySelection(entry);
                }

                if (canEdit)
                {
                    // add the appropriate edit controls
                    CreateEntryEditControls(entry);
                }
            }
            GUILayout.EndHorizontal();
            if (hasChildren)
            {
                parent = entry.name;
                // can't use a foreach because we remove entries, breaks enumeration
                for (var i = 0; i < entry.children.Count; i++)
                {
                    // Debug.Log("Creating child " + child.name + " with offset: " + offset);
                    CreateTreeViewUI(entry.children[i], parent, canEdit, offset);
                }
            }
        }
        /// <summary>
        /// Generate our tree view for the template, with the optional ability to edit it
        /// </summary>
        /// <param name="config">current config that we're viewing / editing</param>
        /// <param name="canEdit">whether we are in edit mode or just read-only</param>
        protected void ViewTemplate(bool canEdit)
        {
            if (!assetLoadComplete)
            {
                LoadAssets();
            }

            GUILayout.BeginVertical();
            {
                // the top info about the template
                if (canEdit)
                {
                    if (Control.activeEntrySelection == null)
                    {
                        GUILayout.Label(Loc.EDIT_FOLDERCONFIGSELECTION_FALSE, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                    }
                    else
                    {
                        GUILayout.Label(Loc.EDIT_FOLDERCONFIGSELECTION_TRUE, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                    }
                }
                else
                {
                    if (windowType == EditorWindowType.TemplateEditor)
                    {
                        if (Control.activeConfig.type == TEMPLATE_TYPE.FOLDER)
                        {
                            GUILayout.Label(Loc.EDIT_VIEWONLYFOLDERDETAILS_EDITOR, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                        }
                        else
                        {
                            GUILayout.Label(Loc.EDIT_VIEWONLYSCENEDETAILS_EDITOR, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                        }
                    }
                    else
                    {
                        if (Control.activeConfig.type == TEMPLATE_TYPE.FOLDER)
                        {
                            GUILayout.Label(Loc.NCW_VIEWONLYFOLDERDETAILS, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                        }
                        else
                        {
                            GUILayout.Label(Loc.NCW_VIEWONLYSCENEDETAILS, EditorStyles.helpBox, GUILayout.MaxWidth(RIGHTPANELWIDTH));
                        }
                    }

                    // these can never be true in read only mode
                    Control.activeConfigEditDirty = false;
                    Control.entryEditDirty        = false;
                }

                GUILayout.BeginHorizontal();
                {
                    // left column
                    var scrollWidth = 200f;
                    _sceneEditScroll = GUILayout.BeginScrollView(_sceneEditScroll, GUILayout.MinWidth(scrollWidth), GUILayout.MaxWidth(scrollWidth), GUILayout.ExpandHeight(true));
                    {
                        // draw our folder view
                        // can't use a foreach because we remove entries, breaks enumeration
                        for (var i = 0; i < Control.activeConfig.entries.Count; i++)
                        {
                            CreateTreeViewUI(Control.activeConfig.entries[i], "", canEdit, 0f);
                        }

                        // only need 'new element' entry if we can edit the template
                        if (canEdit)
                        {
                            // add an entry to add a new root element
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Label(Loc.EDIT_NEWELEMENT);
                                CreateEntryEditControls(null);
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndScrollView();

                    // right detail column
                    GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                    {
                        GUILayout.Space(10f);

                        if (Control.activeEntrySelection != null)
                        {
                            if (Control.activeConfig.type == TEMPLATE_TYPE.FOLDER)
                            {
                                GUILayout.Label(Loc.EDIT_SELECTEDFOLDERENTRY, EditorStyles.boldLabel);
                            }
                            else
                            {
                                GUILayout.Label(Loc.EDIT_SELECTEDSCENEENTRY, EditorStyles.boldLabel);
                            }

                            GUILayout.BeginVertical();
                            {
                                /*
                                 *
                                 * display individual entry in the template
                                 *
                                 */

                                // Top Row - Name
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(Loc.EDIT_SELECTEDENTRYNAME, GUILayout.Width(50f));
                                    // show the editable version if we're in edit mode
                                    if (canEdit)
                                    {
                                        // monitor the text field for changes
                                        EditorGUI.BeginChangeCheck();
                                        {
                                            Control.tempEntrySelectionString = GUILayout.TextField(Control.tempEntrySelectionString, GUILayout.Width(150f));
                                        }
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            Control.entryEditDirty = true;
                                        }

                                        // if they changed the entry name, prompt to save
                                        if (Control.entryEditDirty)
                                        {
                                            // done button
                                            GUI.backgroundColor = Loc.doneColor;
                                            var done = new GUIContent(imgDone, Loc.TOOLTIP_SAVECHANGES);
                                            if (GUILayout.Button(imgDone, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                Control.SaveChangeToEntry(Control.tempEntrySelectionString);
                                            }
                                            // cancel button
                                            GUI.backgroundColor = Loc.cancelColor;
                                            var cancel = new GUIContent(imgCancel, Loc.TOOLTIP_CANCELCHANGES);
                                            if (GUILayout.Button(imgCancel, GUILayout.Width(SMALLBUTTONSIZE), GUILayout.Height(SMALLBUTTONSIZE)))
                                            {
                                                // reset to what it was originally
                                                Control.tempEntrySelectionString = Control.activeEntrySelection.name;
                                                Control.entryEditDirty           = false;
                                            }
                                            // reset colors back to default
                                            GUI.backgroundColor = Loc.defaultColor;
                                        }
                                    }
                                    else
                                    {
                                        // otherwise just the read only version
                                        GUILayout.Label(Control.tempEntrySelectionString, EditorStyles.helpBox, GUILayout.Width(150f));
                                    }
                                }
                                GUILayout.EndHorizontal();

                                // Second row - entry specific elements
                                GUILayout.BeginHorizontal();
                                {
                                    // UI for adding components & their options
                                    CreateComponentEditor(Control.activeEntrySelection, canEdit);
                                }
                                GUILayout.EndHorizontal();
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndHorizontal();

                // bottom 'discard / save' buttons if the user has changed the config
                if (Control.activeConfigEditDirty)
                {
                    GUILayout.BeginVertical();
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(170f);
                            GUILayout.Label(Loc.EDIT_SAVECHANGES);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        {
                            var style = EditorStyles.miniButton;
                            GUI.backgroundColor = Loc.cancelColor;
                            if (GUILayout.Button(Loc.EDIT_SELECTEDENTRYUNDO, style, GUILayout.Width(165f), GUILayout.Height(STANDARDBUTTONHEIGHT)))
                            {
                                Reset();
                            }
                            GUI.backgroundColor = Loc.doneColor;
                            if (GUILayout.Button(Loc.EDIT_SELECTEDENTRYSAVE, style, GUILayout.Width(165f), GUILayout.Height(STANDARDBUTTONHEIGHT)))
                            {
                                Control.SaveConfigChanges();
                            }
                            GUI.backgroundColor = Loc.defaultColor;
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();
                }
            }
            GUILayout.EndVertical();
        }