Exemplo n.º 1
0
        public void OpenNavigateBackMenuAt(IInspector inspector, Rect backButtonRect)
        {
            var menuItems = new List <PopupMenuItem>(currentIndex);

            for (int n = currentIndex - 1; n >= 0; n--)
            {
                TryCreatePopupMenuItem(ref menuItems, n);
            }
            if (menuItems.Count > 0)
            {
                PopupMenuManager.Open(inspector, menuItems, backButtonRect, OnMenuItemClick);
            }
        }
Exemplo n.º 2
0
        public void OpenNavigateForwardMenuAt(IInspector inspector, Rect forwardButtonRect)
        {
            var menuItems    = new List <PopupMenuItem>(currentIndex);
            int historyCount = history.Count;

            for (int n = currentIndex + 1; n < historyCount; n++)
            {
                TryCreatePopupMenuItem(ref menuItems, n);
            }

            if (menuItems.Count > 0)
            {
                PopupMenuManager.Open(inspector, menuItems, forwardButtonRect, OnMenuItemClick);
            }
        }
Exemplo n.º 3
0
        private void OpenTypeSelectorMenu()
        {
                        #if DEV_MODE
            Profiler.BeginSample("PopupMenuSelectableDrawer.OpenMenu");
                        #endif

            if (!menuItemsGenerated)
            {
                menuItemsGenerated = true;

                generatedMenuItems.Clear();
                generatedGroupsByLabel.Clear();
                generatedItemsByLabel.Clear();
                GenerateTypeSelectorMenuItems(ref generatedMenuItems, ref generatedGroupsByLabel, ref generatedItemsByLabel);
            }

            PopupMenuManager.Open(Inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, ControlPosition, OnTargetTypeMenuItemClicked, OnTargetTypeMenuClosed, GUIContentPool.Create("Target Class"), this);
        }
Exemplo n.º 4
0
        private void OpenMenu()
        {
                        #if DEV_MODE
            Profiler.BeginSample("PopupMenuSelectableDrawer.OpenMenu");
                        #endif

            if (!typeContextDetermined)
            {
                typeContextDetermined = true;
                typeContext           = GetTypeContext();
            }

            if (!menuItemsGenerated || menuItemsGeneratedForContext != typeContext)
            {
                menuItemsGenerated = true;

                generatedMenuItems.Clear();
                generatedGroupsByLabel.Clear();
                generatedItemsByLabel.Clear();
                GenerateMenuItems(ref generatedMenuItems, ref generatedGroupsByLabel, ref generatedItemsByLabel);
                menuItemsGeneratedForContext = GetTypeContext();
            }

            tickedMenuItems.Clear();
            GetTickedMenuItems(generatedMenuItems, ref tickedMenuItems);

            var inspector = InspectorUtility.ActiveInspector;

            var openPos = ControlPosition;
            PopupMenuManager.Open(inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, tickedMenuItems, CanTickMultipleItems, openPos, OnPopupMenuItemClicked, OnPopupMenuClosed, MenuLabel(), this);

            if (inspector.Preferences.popupMenusScrollToActiveItem)
            {
                var select = Value;
                if (select != null)
                {
                    PopupMenuManager.SelectItem(GetPopupItemLabel(select));
                }
            }

                        #if DEV_MODE
            Profiler.EndSample();
                        #endif
        }
Exemplo n.º 5
0
        private void OnCreateInstanceButtonClicked()
        {
            DrawGUI.Use(Event.current);

            var nonUnityObjectTypes = NonUnityObjectTypes;
            int count = nonUnityObjectTypes.Length;

            if (count <= 1)
            {
                if (count == 1)
                {
                    SetValueFromType(nonUnityObjectTypes[0]);
                }
                return;
            }

            if (!menuItemsGenerated || menuItemsGeneratedForType != Type)
            {
                generatedMenuItems.Clear();
                generatedGroupsByLabel.Clear();
                generatedItemsByLabel.Clear();
                for (int n = 0; n < count; n++)
                {
                    PopupMenuUtility.BuildPopupMenuItemForType(ref generatedMenuItems, ref generatedGroupsByLabel, ref generatedItemsByLabel, nonUnityObjectTypes[n]);
                }
                menuItemsGenerated        = true;
                menuItemsGeneratedForType = Type;
            }

            var inspector = InspectorUtility.ActiveInspector;

            PopupMenuManager.Open(inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, ControlPosition, OnPopupMenuItemClicked, OnPopupMenuClosed, GUIContentPool.Create("Type"), this);

            if (!IsNull)
            {
                var selectItemOfType = Value.GetType();
                if (selectItemOfType != null)
                {
                    PopupMenuManager.SelectItem(PopupMenuUtility.GetFullLabel(selectItemOfType));
                }
            }
        }
Exemplo n.º 6
0
        private void OpenMenu()
        {
                        #if DEV_MODE
            Profiler.BeginSample("PopupMenuSelectableDrawer.OpenMenu");
                        #endif

            if (!GenerateMenuItemsIfNotGenerated())
            {
                Debug.LogWarning("Can open menu yet. Setup still in progress...");
                return;
            }

            tickedMenuItems.Clear();
            GetTickedMenuItems(generatedMenuItems, ref tickedMenuItems);

            var inspector = InspectorUtility.ActiveInspector;

            var openAt = ControlPosition;

            var offset = GUISpace.ConvertPoint(localDrawAreaOffset, Space.Screen, Space.Local);
            openAt.x += offset.x;
            openAt.y += offset.y;

                        #if DEV_MODE
            Debug.Log(StringUtils.ToColorizedString("openAt=", openAt, ", ControlPosition=", ControlPosition, ", offset=", offset, ", localDrawAreaOffset=", localDrawAreaOffset));
                        #endif

            PopupMenuManager.Open(inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, tickedMenuItems, CanTickMultipleItems, openAt, OnPopupMenuItemClicked, OnPopupMenuClosed, MenuLabel(), this);

            if (inspector.Preferences.popupMenusScrollToActiveItem)
            {
                var select = Value;
                if (select != null)
                {
                    PopupMenuManager.SelectItem(GetPopupItemLabel(select));
                }
            }

                        #if DEV_MODE
            Profiler.EndSample();
                        #endif
        }
Exemplo n.º 7
0
        private void OpenTypeSelectorMenu()
        {
                        #if DEV_MODE
            Profiler.BeginSample("DelegateItemDrawer.OpenTypeSelectorMenu");
                        #endif

            if (!TypeExtensions.IsReady)
            {
                Debug.LogWarning("Can't open menu. Setup still in progress...");
                return;
            }

            if (!menuItemsGenerated)
            {
                menuItemsGenerated = true;

                generatedMenuItems.Clear();
                generatedGroupsByLabel.Clear();
                generatedItemsByLabel.Clear();
                GenerateTypeSelectorMenuItems(ref generatedMenuItems, ref generatedGroupsByLabel, ref generatedItemsByLabel);
            }

            PopupMenuManager.Open(Inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, ControlPosition, OnTargetTypeMenuItemClicked, OnTargetTypeMenuClosed, GUIContentPool.Create("Target Class"), this);
        }
Exemplo n.º 8
0
        static PopupMenuWindowAttacher()
        {
            var attacher = new PopupMenuWindowAttacher();

            PopupMenuManager.RegisterPopupMenuDrawer(attacher);
        }