Exemplo n.º 1
0
        public static HierarchyProEditorGroupLine Create(HierarchyProGroup group, Rect rect, int indent)
        {
            HierarchyProEditorGroupLine groupLine = new HierarchyProEditorGroupLine(group, rect, indent);

            groupLine.Initialize();
            return(groupLine);
        }
Exemplo n.º 2
0
        private static void Delete(object userdata)
        {
            HierarchyProGroup group = (HierarchyProGroup)userdata;

            HierarchyProGroupLibrary.Delete(group);
            HierarchyProEditorGroupWindow.Redraw();
        }
        private void Drop(HierarchyProGroup dragGroup, Vector2 dropPosition)
        {
            foreach (HierarchyProEditorGroupLine line in this.groupData)
            {
                Rect dropRect = line.Rect;
                if (line.Group == this.dragging)
                {
                    dropRect.width = 16;
                }
                if (dropRect.Contains(dropPosition))
                {
                    if (line.Group == dragGroup)
                    {
                        // Dropped line on itself.
                        dragGroup.Parent = null;
                        return;
                    }

                    if (line.Group.IsChildOf(dragGroup))
                    {
                        line.Group.Parent = null;
                    }
                    dragGroup.Parent = line.Group;
                }
            }
        }
Exemplo n.º 4
0
        private static void Rename(object userdata)
        {
            HierarchyProGroup group = (HierarchyProGroup)userdata;

            HierarchyProEditorGroupWindow.Renaming     = group;
            HierarchyProEditorGroupWindow.RenamingName = group.Name;
        }
Exemplo n.º 5
0
        public static HierarchyProGroup Create()
        {
            HierarchyProGroup group = new HierarchyProGroup();

            group.id       = HierarchyProGroupLibrary.GetID();
            group.parentID = 0;
            return(group);
        }
        private void OnGUI()
        {
            Rect window  = this.position;
            Rect toolbar = new Rect(0, 0, window.width, 18);
            Rect rect    = new Rect(0, toolbar.yMax, window.width, window.height - toolbar.yMax);

            GUI.Label(toolbar, GUIContent.none, HierarchyProEditorStyles.ToolbarHorizontal);
            this.DrawToolbar(toolbar);

            if (HierarchyProGroupLibrary.Count == 0)
            {
                HierarchyProEditorGroupWindow.DrawNoGroupsMessage(rect);
                return;
            }

            this.groupData = HierarchyProEditorGroupWindow.StackGroups(rect).ToList();
            float height     = (this.groupData != null) && this.groupData.Any() ? this.groupData.Max(x => x.Rect.yMax) - rect.y : 0;
            Rect  scrollRect = new Rect(rect)
            {
                width = rect.width - 18, height = height
            };

            this.scrollPosition = GUI.BeginScrollView(rect, this.scrollPosition, scrollRect);

            this.trackDrag.Update(Event.current);
            this.HandleNativeDrag();

            bool hasScrollbar = scrollRect.height > rect.height;

            foreach (HierarchyProEditorGroupLine line in this.groupData)
            {
                bool dragOver = false;
                if (this.dragging != null)
                {
                    Rect dropRect = line.Rect;
                    if (line.Group == this.dragging)
                    {
                        dropRect.width = 16;
                    }
                    if (dropRect.Contains(this.dragPosition))
                    {
                        dragOver = true;
                    }
                }

                line.Draw(hasScrollbar, dragOver);
            }
            if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
            {
                HierarchyProEditorGroupWindow.Selected = null;
                this.renaming = null;
                this.Repaint();
            }

            GUI.EndScrollView();
        }
Exemplo n.º 7
0
        private HierarchyProEditorGroupLine(HierarchyProGroup group, Rect rect, int indent)
            : this()
        {
            this.group  = group;
            this.rect   = rect;
            this.indent = indent;

            this.transforms     = new List <Transform>();
            this.rectTransforms = new List <RectTransform>();
        }
        private void TrackDragOnDrop(Vector2 start, Vector2 drop)
        {
            if (this.dragging == null)
            {
                return;
            }

            this.Drop(this.dragging, drop);
            this.dragging = null;
        }
 private void TrackDragOnDrag(Vector2 start)
 {
     foreach (HierarchyProEditorGroupLine line in this.groupData)
     {
         if (line.Rect.Contains(start))
         {
             this.dragging = line.Group;
             HierarchyProEditorGroupWindow.Selected = line.Group;
             this.Repaint();
         }
     }
 }
Exemplo n.º 10
0
        public bool IsChildOf(HierarchyProGroup group)
        {
            HierarchyProGroup child = this;

            while (child.Parent != group)
            {
                if (child.Parent == null)
                {
                    return(false);
                }
                child = child.Parent;
            }
            return(true);
        }
        public static IHierarchyProNote Create(HierarchyProGroup group)
        {
            HierarchyProNoteGroup existingNote = HierarchyProNotesLibrary.GroupNotes.FirstOrDefault(x => x.Group == group);

            if (existingNote != null)
            {
                return(existingNote);
            }

            HierarchyProNoteGroup        note  = new HierarchyProNoteGroup(group);
            List <HierarchyProNoteGroup> notes = HierarchyProNotesLibrary.GroupNotes.ToList();

            notes.Add(note);
            HierarchyProNotesLibrary.Instance.groupNotes = notes.ToArray();
            return(note);
        }
        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();
            }
        }
Exemplo n.º 13
0
        public static void Draw(Rect rect, HierarchyProGroup group)
        {
            IHierarchyProNote note = HierarchyProNotesLibrary.Find(group);
            bool clicked           = HierarchyProEditorNotes.Draw(rect, note);

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

                HierarchyProEditorNoteWindow content = new HierarchyProEditorNoteWindow(note);
                PopupWindow.Show(rect, content);
            }
        }
Exemplo n.º 14
0
 public HierarchyProNoteGroup(HierarchyProGroup group)
 {
     this.GroupID = group.ID;
 }
Exemplo n.º 15
0
 public void RemoveObjects(IEnumerable <Object> objects)
 {
     this.RemoveTransforms(HierarchyProGroup.GetTransforms(objects));
 }
        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);
                }
            }
        }
 public static IHierarchyProNote Find(HierarchyProGroup group)
 {
     return(HierarchyProNotesLibrary.GroupNotes.FirstOrDefault(x => x.Group == group));
 }
Exemplo n.º 18
0
 public void AddObjects(IEnumerable <Object> objects)
 {
     this.AddTransforms(HierarchyProGroup.GetTransforms(objects));
 }
Exemplo n.º 19
0
        private static void SelectionAdd(object userdata)
        {
            HierarchyProGroup group = (HierarchyProGroup)userdata;

            group.AddObjects(Selection.objects);
        }
Exemplo n.º 20
0
        private static void SelectionRemove(object userdata)
        {
            HierarchyProGroup group = (HierarchyProGroup)userdata;

            group.RemoveObjects(Selection.objects);
        }