private void DrawColorPicker(Rect rect) { int rows = 2; int columns = 10; float width = rect.width / columns; float height = rect.height / rows; for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { Rect colorRect = new Rect(rect) { x = rect.x + (width * x), y = rect.y + (height * y), width = width, height = height }; int index = x + (y * columns); Color color = HierarchyProEditorNoteWindow.colors[index]; EditorGUI.DrawRect(colorRect, color); if (GUI.Button(colorRect, GUIContent.none, GUIStyle.none)) { this.note.ColorBackground = color; EditorApplication.RepaintHierarchyWindow(); HierarchyProEditorGroupWindow.Redraw(); } } } }
private static void Delete(object userdata) { HierarchyProGroup group = (HierarchyProGroup)userdata; HierarchyProGroupLibrary.Delete(group); HierarchyProEditorGroupWindow.Redraw(); }
private void DrawHeader(Rect rect) { Rect iconRect = new Rect(rect) { x = rect.x + 5, width = 16 }; foreach (Texture icon in HierarchyProEditorNoteWindow.Icons) { if (this.note.Icon == icon) { EditorGUI.DrawRect(iconRect, GUI.skin.settings.selectionColor); } if (icon != null) { GUI.DrawTexture(iconRect.GetCenteredIconRect(icon, 16, 16), icon); } if (GUI.Button(iconRect, GUIContent.none, GUIStyle.none)) { this.note.Icon = icon; EditorApplication.RepaintHierarchyWindow(); HierarchyProEditorGroupWindow.Redraw(); } iconRect = new Rect(iconRect) { x = iconRect.x + 16 }; } float x = iconRect.x + 5; Rect colorFore = new Rect(rect) { x = x, width = rect.width - x - 26 }; this.DrawColorPicker(colorFore); Rect rectDelete = new Rect(colorFore) { x = colorFore.x + colorFore.width + 5, width = 16 }; GUI.color = new Color(0.3f, 0.3f, 0.3f); GUI.DrawTexture(rectDelete.GetCenteredIconRect(HierarchyProEditorIcons.Delete), HierarchyProEditorIcons.Delete); GUI.color = Color.white; if (GUI.Button(rectDelete, GUIContent.none, GUIStyle.none)) { if (EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to delete this note?", "Yes", "No")) { this.editorWindow.Close(); HierarchyProNotesLibrary.Delete(this.note); EditorApplication.RepaintHierarchyWindow(); HierarchyProEditorGroupWindow.Redraw(); } } }
private static void Update() { if (HierarchyPro.RedrawPending) { EditorApplication.RepaintHierarchyWindow(); } if (HierarchyProEditorGroupWindow.RedrawPending) { HierarchyProEditorGroupWindow.Redraw(); } }
public void Draw(bool hasScrollbar, bool dragOver) { Rect lineRect = this.Rect; if (hasScrollbar) { lineRect.width -= 18; } if (HierarchyProEditorGroupWindow.Renaming == this.Group) { HierarchyProEditorGroupWindow.RenamingName = GUI.TextField(new Rect(lineRect) { x = lineRect.x + 16, width = lineRect.width - 16 }, HierarchyProEditorGroupWindow.RenamingName); if ((Event.current.keyCode == KeyCode.Return) || (Event.current.keyCode == KeyCode.KeypadEnter)) { this.Group.Name = HierarchyProEditorGroupWindow.RenamingName; HierarchyProEditorGroupWindow.Renaming = null; HierarchyProEditorGroupWindow.Redraw(); } if (Event.current.keyCode == KeyCode.Escape) { HierarchyProEditorGroupWindow.Renaming = null; HierarchyProEditorGroupWindow.Redraw(); } return; } if (lineRect.Contains(Event.current.mousePosition)) { if (Event.current.keyCode == KeyCode.Delete) { HierarchyProGroupLibrary.Delete(this.Group); Event.current.Use(); } } if (HierarchyProEditorGroupWindow.Selected == this.Group) { EditorGUI.DrawRect(lineRect, GUI.skin.settings.selectionColor); } Rect labelRect = new Rect(lineRect) { x = 16 + (this.Indent * 16) }; if (this.group.HasChildren) { this.group.ShowChildren = EditorGUI.Foldout(new Rect(labelRect) { x = labelRect.x - 16, width = 16 }, this.group.ShowChildren, GUIContent.none); } GUI.Label(labelRect, this.Name); bool collapseCount = HierarchyProEditorGroupWindow.Width <= 225; Rect rectActive = new Rect(lineRect) { x = lineRect.xMax - 16, width = 16 }; Rect rectLocked = new Rect(rectActive) { x = rectActive.x - 16 }; Rect rectNotes = new Rect(rectLocked) { x = rectLocked.x - 12 }; Rect rectDivider1 = new Rect(rectNotes) { x = rectNotes.x - 2, width = 1 }; Rect rectCount = new Rect(lineRect) { x = rectDivider1.x - 56, width = 56 }; Rect rectDivider2 = new Rect(rectCount) { x = rectCount.x - 4, width = 1 }; Rect rectSelect = new Rect(lineRect) { x = (collapseCount ? rectDivider1 : rectDivider2).x - 12, width = 12 }; Rect rectAddRemove = new Rect(rectActive) { x = rectSelect.x - 24, width = 24 }; Rect rectControlArea = new Rect(lineRect) { xMin = rectAddRemove.x, xMax = rectActive.xMax }; EditorGUI.DrawRect(rectControlArea, HierarchyProEditorColors.Background); this.DrawActive(rectActive); this.DrawLocked(rectLocked); HierarchyProEditorNotes.Draw(rectNotes, this.group); EditorGUI.DrawRect(rectDivider1, EditorGUIUtility.isProSkin ? new Color(0.1f, 0.1f, 0.1f) : new Color(0.6f, 0.6f, 0.6f)); if (!collapseCount) { this.DrawCount(rectCount); EditorGUI.DrawRect(rectDivider2, EditorGUIUtility.isProSkin ? new Color(0.1f, 0.1f, 0.1f) : new Color(0.6f, 0.6f, 0.6f)); } this.DrawSelect(rectSelect); this.DrawAddRemove(rectAddRemove); if (GUI.Button(new Rect(labelRect) { width = rectSelect.x - labelRect.x }, GUIContent.none, GUIStyle.none)) { HierarchyProEditorGroupWindow.Selected = this.Group; if (Event.current.button == 1) { this.ShowContextMenu(); } } if (dragOver) { if (HierarchyProEditorGroupWindow.Dragging == this.group) { GUI.Label(new Rect(lineRect) { width = 16 }, GUIContent.none, HierarchyProEditorStyles.DropHighlight); } else { GUI.Label(lineRect, GUIContent.none, HierarchyProEditorStyles.DropHighlight); } } }