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

            HierarchyProGroupLibrary.Delete(group);
            HierarchyProEditorGroupWindow.Redraw();
        }
コード例 #2
0
        public static HierarchyProGroup Create()
        {
            HierarchyProGroup group = new HierarchyProGroup();

            group.id       = HierarchyProGroupLibrary.GetID();
            group.parentID = 0;
            return(group);
        }
コード例 #3
0
        private static void StackGroupsRecursive(ref List <HierarchyProEditorGroupLine> lines, ref Rect lineRect, HierarchyProGroup group, int indent = 0)
        {
            lines.Add(HierarchyProEditorGroupLine.Create(group, lineRect, indent));
            lineRect.y += lineRect.height;

            if (group.ShowChildren)
            {
                IEnumerable <HierarchyProGroup> children = HierarchyProGroupLibrary.FindChildren(group).ToList();
                group.HasChildren = children.Any();
                foreach (HierarchyProGroup child in children)
                {
                    HierarchyProEditorGroupWindow.StackGroupsRecursive(ref lines, ref lineRect, child, indent + 1);
                }
            }
        }
コード例 #4
0
        private void DrawToolbar(Rect rect)
        {
            Rect add = new Rect(rect)
            {
                x = rect.x + 6, width = 52
            };

            if (GUI.Button(add, "Create", EditorStyles.toolbarButton))
            {
                HierarchyProGroup group = HierarchyProGroup.Create();
                group.AddObjects(Selection.objects);
                if (HierarchyProEditorGroupWindow.Selected != null)
                {
                    group.Parent = HierarchyProEditorGroupWindow.Selected;
                }
                group.GenerateName();

                HierarchyProGroupLibrary.Add(group);
                HierarchyProEditorGroupWindow.Selected = group;

                EditorUtility.SetDirty(HierarchyProGroupLibrary.Instance);
            }

            Rect settings = new Rect(rect)
            {
                x = rect.xMax - 32, width = 26
            };

            if (GUI.Button(settings, new GUIContent(HierarchyProEditorIcons.Cog), EditorStyles.toolbarButton))
            {
                if (Event.current.control)
                {
                    Object.DestroyImmediate(HierarchyProGroupLibrary.Instance.gameObject);
                }
                if (Event.current.shift)
                {
                    Selection.activeObject = HierarchyProGroupLibrary.Instance.gameObject;
                }

                Vector2 centerScreen                = new Vector2(Screen.width / 2f, Screen.height / 2f);
                Vector2 rectPreferencesSize         = new Vector2(500, 340);
                var     rectPreferencesCenter       = centerScreen - (rectPreferencesSize / 2f);
                Rect    rectPreferences             = new Rect(rectPreferencesCenter.x, rectPreferencesCenter.y, rectPreferencesSize.x, rectPreferencesSize.y);
                HierarchyProPreferences preferences = EditorWindow.GetWindowWithRect <HierarchyProPreferences>(rectPreferences, true, "HierarchyPro Preferences", true);
                preferences.Show();
            }
        }
コード例 #5
0
        public static HierarchyProGroupLibrary FindInstance()
        {
            if ((HierarchyProGroupLibrary.instance != null) && (HierarchyProGroupLibrary.instance.gameObject != null))
            {
                return(HierarchyProGroupLibrary.instance);
            }

            HierarchyProGroupLibrary.instance = Object.FindObjectOfType <HierarchyProGroupLibrary>();
            if ((HierarchyProGroupLibrary.instance != null) && (HierarchyProGroupLibrary.instance.gameObject != null))
            {
                return(HierarchyProGroupLibrary.instance);
            }

            GameObject gameObject = GameObject.Find("HierarchyPro Data") ?? new GameObject("HierarchyPro Data");

            gameObject.hideFlags = HideFlags.DontSaveInBuild | HideFlags.HideInHierarchy;
            HierarchyProGroupLibrary library = gameObject.AddComponent <HierarchyProGroupLibrary>();

            HierarchyProGroupLibrary.instance = library;
            return(HierarchyProGroupLibrary.instance);
        }
コード例 #6
0
        private static void Load()
        {
            HierarchyProPreferences.Load();

            HierarchyProEditorCache.Initialize();
            HierarchyProEditorReflection.Load();
            HierarchyProEditorIcons.Load();
            HierarchyProEditorColors.Load();
            HierarchyProEditorStyles.Load();

            HierarchyProGroupLibrary.FindInstance();

            EditorApplication.update -= HierarchyProEditorLoader.Update;
            EditorApplication.hierarchyWindowChanged   -= HierarchyProEditorLoader.WindowChanged;
            EditorApplication.hierarchyWindowItemOnGUI -= HierarchyProEditorLoader.ItemOnGUI;
            Undo.undoRedoPerformed -= HierarchyProEditorLoader.UndoRedoPerformed;

            EditorApplication.update += HierarchyProEditorLoader.Update;
            EditorApplication.hierarchyWindowChanged   += HierarchyProEditorLoader.WindowChanged;
            EditorApplication.hierarchyWindowItemOnGUI += HierarchyProEditorLoader.ItemOnGUI;
            Undo.undoRedoPerformed += HierarchyProEditorLoader.UndoRedoPerformed;
        }
コード例 #7
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);
                }
            }
        }