public void OnGUI() { ResourceUtil.Refresh(); InitEditorStyles(); // Is sub window activated ? if (nfsi != null) { currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos); nfsi.OnInspectorGUI(this); EditorGUILayout.EndScrollView(); return; } if (!TitleBarGUI()) { return; } // Custom style foldout currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos); EditorGUILayout.BeginHorizontal(toolBarStyle); EditorGUILayout.LabelField("Project styles:", toolBarLabelStyle); GUILayout.FlexibleSpace(); if (GUILayout.Button(GUIHelper.ContentFromEditor("New", "Toolbar Plus"), toolBarButtonStyle)) { nfsi = new NewFolderStyleInspector(null, false); } EditorGUILayout.EndHorizontal(); GUILayout.BeginVertical(styleListBackgroundStyle); GUILayout.Space(6); ButtonGrid.ButtonAction styleAction = customStyles.DrawGrid(); if (styleAction != null) { if (styleAction.IsLeftClick) { ApplyStyle((StyleGrid.StyleElement)styleAction.ClickedElement); } else { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Create variant"), false, CreateVariant, (StyleGrid.StyleElement)styleAction.ClickedElement); menu.AddItem(new GUIContent("Edit"), false, EditStyle, (StyleGrid.StyleElement)styleAction.ClickedElement); menu.AddItem(new GUIContent("Delete"), false, AskDeleteStyle, (StyleGrid.StyleElement)styleAction.ClickedElement); menu.ShowAsContext(); } } GUILayout.Space(2); GUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(toolBarStyle); GUILayout.FlexibleSpace(); /*if (GUILayout.Button("Download Style packs", toolBarButtonStyle)) * { * //nfsi = new NewFolderStyleInspector(); * }*/ EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); }
/// <summary> /// Define window layout /// </summary> /// <param name="fI"></param> public void OnInspectorGUI(FolderInspector fI) { InitTextures(); //// Header GUILayout.BeginHorizontal(FolderInspector.titleBarStyle); string headerTitle = (editStyle != null ? " Edit" : " New") + " style: "; GUIContent folderGuiContent = GUIHelper.ContentFromAssets(headerTitle, ResourceUtil.TexturesPath + "/folder_icon_16.png"); GUILayout.Label(folderGuiContent); GUILayout.FlexibleSpace(); // Name field GUILayout.BeginHorizontal(); GUILayout.Label("Name:", FolderInspector.titleBarLabelStyle); string newStyleName = EditorGUILayout.TextField(styleName, FolderInspector.titleBarTextFieldStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150.0f)); if (!styleName.Equals(newStyleName)) { styleName = newStyleName; nameEdited = true; } GUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); ColorGUI(); // Icons IconGUI(); GUILayout.Space(2); //// Preview // Real time change pixels if (PreferencesUI.settings.useNewUI) { UpdateTextureColor(folderOriginalTexture64, folderTexture64, -7, 2, 96, 80, 16, 24, 2.0F); UpdateTextureColor(folderOriginalTexture16, folderTexture16, 1, 3, 15, 13, 2, 3, 0.25F); Vector2Int offset = GetClampedBigIconOffset(); UpdateTextureColor(folderOriginalIcon24, folderIcon24, 32 + offset.x - 3, 14 - offset.y + 1, 48, 40, 8, 16, 1.0F); offset = GetClampedSmallIconOffset(); UpdateTextureColor(folderOriginalIcon10, folderIcon10, 6 + offset.x + 1, -offset.y + 3, 15, 13, 2, 3, 0.25F); } else { UpdateTextureColor(folderOriginalTexture64, folderTexture64, 3, 7, 56, 50, 3, 10, 1.0F); UpdateTextureColor(folderOriginalTexture16, folderTexture16, 2, 3, 15, 13, 0, 1, 0.25F); Vector2Int offset = GetClampedBigIconOffset(); UpdateTextureColor(folderOriginalIcon24, folderIcon24, 32 + offset.x + 3, 14 - offset.y + 6, 56, 50, 4, 10, 1.0F); offset = GetClampedSmallIconOffset(); UpdateTextureColor(folderOriginalIcon10, folderIcon10, 6 + offset.x + 2, -offset.y + 3, 15, 13, 0, 1, 0.25F); } GUILayout.BeginVertical(); PreviewGUI(); //// Button pannel ControlsGUI(fI); GUILayout.EndVertical(); }