private static void OnHierarchyItemGUI(int id, Rect rect)
        {
            if (!prefs.enableSmartHierarchy)
            {
                return;
            }

            lastHierarchy = HierarchyInitialization.GetLastHierarchy();

            lastHierarchy.OnItemCallback(id, rect);
        }
        internal static SmartHierarchy GetLastHierarchy()
        {
            var lastHierarchyWindow = getLastHierarchyWindowFunc();

            if (!Hierarchies.TryGetValue(lastHierarchyWindow, out var hierarchy))
            {
                hierarchy = new SmartHierarchy(lastHierarchyWindow as EditorWindow);
                Hierarchies.Add(lastHierarchyWindow, hierarchy);
            }
            return(hierarchy);
        }
Beispiel #3
0
        public static void DoItemGUI(this ViewItem item, SmartHierarchy hierarchy, Rect rect, bool isHover, bool isOn)
        {
            item.DrawIcon(rect, isOn);

            if (item.isCollection)
            {
                if (OnIconClick(rect))
                {
                    var collectionPopup = ObjectPopupWindow.GetPopup <CollectionPopup>();
                    if (collectionPopup == null)
                    {
                        var popup = new CollectionPopup(item.collection);

                        var scrollPos = hierarchy.state.scrollPos.y;
                        var position  = new Vector2(rect.x, rect.yMax - scrollPos + 32);

                        popup.ShowInsideWindow(position, hierarchy.root);
                    }
                    else
                    {
                        collectionPopup.Close();
                    }
                }
            }

            var fullWidthRect = new Rect(rect)
            {
                x = 0, width = Screen.width
            };
            var toggleRect = new Rect(fullWidthRect)
            {
                x = 32
            };

            var isDragged = activationToggle.IsObjectDragged(item.instance);

            if (isDragged)
            {
                var c = EditorGUIUtility.isProSkin ? new Color(1, 1, 1, 1) : new Color(0, 0, 0, 1);
                EditorGUI.DrawRect(toggleRect, new Color(c.r, c.g, c.b, 0.0666f));
            }

            activationToggle.DoActivationToggle(toggleRect, item.instance, isHover || isDragged);
        }