Exemplo n.º 1
0
        protected bool OpenContextMenu([NotNull] Event inputEvent, bool extendedMenu)
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(inputEvent != null);
            Debug.Assert(!inputEvent.isMouse || !inspector.IgnoreToolbarMouseInputs());
                        #endif

            var menu = Menu.Create();
            BuildContextMenu(ref menu, extendedMenu);

                        #if DEV_MODE && UNITY_EDITOR
            if (extendedMenu)
            {
                AddDevModeDebuggingEntriesToRightClickMenu(ref menu);
            }
                        #endif

            if (menu.Count == 0)
            {
                menu.Dispose();
                return(false);
            }

            if (inputEvent.type != EventType.Used)
            {
                inputEvent.Use();
            }

            ContextMenuUtility.OpenAt(menu, Bounds, true, inspector, InspectorPart.Toolbar, null, this);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary> Opens menu to specify search type. </summary>
        /// <param name="position"> The position of the menu. </param>
        private void OpenFilteringMethodMenu(Rect position)
        {
                        #if DEV_MODE
            Debug.Log("OpenFilteringMethodMenu");
                        #endif

            var menu = Menu.Create();

            var currentFilteringMethod = inspector.State.filter.FilteringMethod;

            menu.Add("Any", SetFilteringMethodToAll, currentFilteringMethod == FilteringMethod.Any);
            menu.AddSeparator();
            menu.Add("Label", SetFilteringMethodToLabel, currentFilteringMethod == FilteringMethod.Label);
            menu.Add("Type", SetFilteringMethodToType, currentFilteringMethod == FilteringMethod.Type);
            menu.Add("Value", SetFilteringMethodToValue, currentFilteringMethod == FilteringMethod.Value);
            menu.AddSeparator();
            menu.Add("Class", SetFilteringMethodToClass, currentFilteringMethod == FilteringMethod.Class);
            menu.Add("Scene", SetFilteringMethodToScene, currentFilteringMethod == FilteringMethod.Scene);
            menu.Add("Asset", SetFilteringMethodToAsset, currentFilteringMethod == FilteringMethod.Asset);
            menu.Add("Window", SetFilteringMethodToWindow, currentFilteringMethod == FilteringMethod.Window);
            menu.Add("Icon", SetFilteringMethodToIcon, currentFilteringMethod == FilteringMethod.Icon);
            menu.AddSeparator();
            menu.Add("Help", OpenDocumentationPage);

            ContextMenuUtility.OpenAt(menu, position, true, inspector, InspectorPart.Toolbar, null, SearchBoxPart.Dropdown, OnFilteringMethodMenuClosed);
        }
Exemplo n.º 3
0
        private void OnToggleSnapToGridIconRightClicked(IUnityObjectDrawer containingDrawer, Rect buttonRect, Event inputEvent)
        {
            var menu = Menu.Create();

            menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings..."));
            ContextMenuUtility.OpenAt(menu, buttonRect, this, (Part)TransformHeaderPart.ToggleSnapToGridButton);
        }
Exemplo n.º 4
0
 /// <inheritdoc />
 public override bool OnRightClick(Event inputEvent)
 {
     if (MouseoveredHeaderPart == (HeaderPart)TransformHeaderPart.ToggleSnapToGridButton)
     {
         var menu = Menu.Create();
         menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings..."));
         ContextMenuUtility.OpenAt(menu, ToggleSnapToGridIconPosition, this, (Part)TransformHeaderPart.ToggleSnapToGridButton);
         return(true);
     }
     return(base.OnRightClick(inputEvent));
 }
Exemplo n.º 5
0
        /// <summary> Opens execute method menu. </summary>
        public static void OpenExecuteMethodMenu([NotNull] IUnityObjectDrawer subject, Rect position, bool includeInvisible)
        {
            var menu = GenerateExecuteMethodMenu(subject.UnityObject, subject.Type, includeInvisible);

            if (menu.Count > 0)
            {
                ContextMenuUtility.OpenAt(menu, position, subject, Part.MethodInvokerButton);
            }
                        #if DEV_MODE
            else
            {
                Debug.LogWarning(subject + ".GenerateExecuteMethodMenu with type " + StringUtils.ToString(subject.Type) + " returned zero menu items");
            }
                        #endif
        }
        /// <inheritdoc />
        public sealed override bool DrawPrefix(Rect position)
        {
            bool dirty = base.DrawPrefix(position);

            if (DrawSnapIcon)
            {
                var snapButtonRect = SnappingIconPosition;
                var settings       = InspectorUtility.Preferences;
                var graphics       = settings.graphics;

                if (Event.current.type == EventType.Repaint)
                {
                    if (SnappingEnabled)
                    {
                        GUI.DrawTexture(snapButtonRect, graphics.SnappingOnIcon, ScaleMode.StretchToFill);
                    }
                    else
                    {
                        var guiColorWas = GUI.color;
                        var setGuiColor = guiColorWas;
                        setGuiColor.a = 0.5f;
                        GUI.color     = setGuiColor;
                        GUI.DrawTexture(snapButtonRect, graphics.SnappingOffIcon, ScaleMode.StretchToFill);
                        GUI.color = guiColorWas;
                    }
                }

                if (GUI.Button(snapButtonRect, GUIContent.none, DrawGUI.prefixLabel))
                {
                    if (Event.current.button == 0)
                    {
                        ToggleSnapping();
                        return(true);
                    }
                    if (Event.current.button == 1)
                    {
                        var menu = Menu.Create();
                        menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings..."));
                        ContextMenuUtility.OpenAt(menu, snapButtonRect, this, (Part)TransformHeaderPart.ToggleSnapToGridButton);
                        return(true);
                    }
                }
            }

            return(dirty);
        }