private void OnAfterGUI()
        {
            if (!prefs.enableSmartHierarchy)
            {
                return;
            }

            if (EditorWindow.focusedWindow != actualWindow)
            {
                ObjectPopupWindow.Close();
            }

            HandleKeyboard();

            // Mouse is relative to window during onGUIHandler
            if (evt.type != EventType.Used)
            {
                localMousePosition = evt.mousePosition;

                hoverPreview.SetPosition(localMousePosition, actualWindow.position);
            }

            HandleObjectPreview();

            requiresUpdateBeforeGUI = true;
        }
Пример #2
0
        private void OnAfterGUI()
        {
            if (!prefs.enableSmartHierarchy)
            {
                return;
            }

            // Makes sure other items like scene headers are not interrupted
            controller.gui.ResetCustomStyling();

            if (EditorWindow.focusedWindow != actualWindow)
            {
                ObjectPopupWindow.Close();
            }

            HandleKeyboard();

            // Mouse is relative to window during onGUIHandler
            if (evt.type != EventType.Used)
            {
                localMousePosition = evt.mousePosition;

                hoverPreview.SetPosition(localMousePosition, actualWindow.position);
            }

            HandleObjectPreview();

            requiresUpdateBeforeGUI = true;
        }
Пример #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);
        }
        public SmartHierarchy(EditorWindow window)
        {
            root        = window.rootVisualElement;
            this.window = new SceneHierarchyWindow(window);

            hoverPreview = new HoverPreview();

            Initialize();
            RegisterCallbacks();
            hierarchy.ReassignCallbacks();

            guiContainer = root.parent.Query <IMGUIContainer>().First();
            guiContainer.RegisterCallback <MouseDownEvent>(_ => ObjectPopupWindow.Close());

            // onGUIHandler is called after hierarchy GUI, thus has a slight delay
            guiContainer.onGUIHandler += OnAfterGUI;

            root.Add(hoverPreview);
        }