예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        public static void Draw(Rect rect, Transform transform)
        {
            IHierarchyProNote note = HierarchyProNotesLibrary.Find(transform);
            bool clicked           = HierarchyProEditorNotes.Draw(rect, note);

            if (clicked)
            {
                if (note == null)
                {
                    note      = HierarchyProNotesLibrary.Create(transform);
                    note.Icon = HierarchyProEditorIcons.Note;
                }

                HierarchyProEditorNoteWindow content = new HierarchyProEditorNoteWindow(note);
                PopupWindow.Show(rect, content);
            }
        }
        public static HierarchyProNotesLibrary FindInstance()
        {
            if ((HierarchyProNotesLibrary.instance != null) && (HierarchyProNotesLibrary.instance.gameObject != null))
            {
                return(HierarchyProNotesLibrary.instance);
            }

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

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

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

            HierarchyProNotesLibrary.instance = library;
            return(HierarchyProNotesLibrary.instance);
        }