/// <summary> /// Draws our top header /// </summary> /// <param name="windowType"></param> protected void DrawBanner(CONTENTWINDOW windowType) { switch (windowType) { case CONTENTWINDOW.NEWCONTENTWIZARD: { // load the proper banner if (bannerLogoNewContent == null) { bannerLogoNewContent = new Texture2D(32, 32); bannerLogoNewContent = AssetDatabase.LoadAssetAtPath <Texture2D>(EditorUtilities.packagePathRoot + "/Module.NewContentWizard/Content/White/Banner/NewContentWizard.png"); } break; } case CONTENTWINDOW.TEMPLATEEDITOR: { if (bannerLogoTemplateEditor == null) { bannerLogoTemplateEditor = new Texture2D(32, 32); bannerLogoTemplateEditor = AssetDatabase.LoadAssetAtPath <Texture2D>(EditorUtilities.packagePathRoot + "/Module.NewContentWizard/Content/White/Banner/TemplateEditor.png"); } break; } } if (headerBG == null) { headerBG = new GUIStyle(); var background = AssetDatabase.LoadAssetAtPath <Texture2D>(EditorUtilities.packagePathRoot + "/Module.NewContentWizard/Content/White/Banner/Background.png"); headerBG.normal.background = background; } GUILayout.BeginHorizontal(headerBG, GUILayout.MinWidth(position.width)); { switch (windowType) { case CONTENTWINDOW.NEWCONTENTWIZARD: { GUILayout.Label(bannerLogoNewContent); break; } case CONTENTWINDOW.TEMPLATEEDITOR: { GUILayout.Label(bannerLogoTemplateEditor); break; } } } 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(); }