コード例 #1
0
        private static void Delete(object userdata)
        {
            HierarchyProGroup group = (HierarchyProGroup)userdata;

            HierarchyProGroupLibrary.Delete(group);
            HierarchyProEditorGroupWindow.Redraw();
        }
コード例 #2
0
        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);
                }
            }
        }