Пример #1
0
        /// <summary>
        /// Determines if the item can be displayed
        /// </summary>
        /// <param name="groupPath">The path of the group to evaluate</param>
        /// <param name="items">The items that will be displayed</param>
        /// <returns>True if the group can be displayed, false if not</returns>
        private bool CanDisplay(string groupPath,
                                IEnumerable <GUIGenericMenuItem> items)
        {
            if (selectedPaths.Count < 1)
            {
                return(true);
            }

            GUIGroupMenuItem deepestGroup = selectedPaths[selectedPaths.Count - 1];

            if (!items.Contains(deepestGroup))
            {
                return(true);
            }

            if (deepestGroup.PositionRect.Contains(Event.current.mousePosition) ||
                deepestRect.Contains(Event.current.mousePosition))
            {
                return(true);
            }

            if (!canRemove)
            {
                return(true);
            }

            selectedPaths.RemoveAt(selectedPaths.Count - 1);
            canRemove = false;
            GUIUtility.ExitGUI();
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Callback for group menu items to handle adding the group
        /// to the collection of selected items
        /// </summary>
        /// <param name="groupObject">The group menu item to be added to the currently
        /// selected</param>
        private void AddPathToActive(GUIMenuItemParamEventArgs args)
        {
            GUIGroupMenuItem groupItem = args.SelectedItem as GUIGroupMenuItem;

            if (groupItem == null)
            {
                return;
            }

            selectedPaths.AddUnique(groupItem);
        }
Пример #3
0
        /// <summary>
        /// Renders the menu item if it's currently shown
        /// </summary>
        public void Draw()
        {
            selectedItem = null;

            if (!IsShown)
            {
                return;
            }

            List <GUIGenericMenuItem> rootGroup;

            if (!groupedMenuItems.TryGetValue(string.Empty, out rootGroup))
            {
                return;
            }

            DrawGroup(new Rect(drawPosition, Vector2.zero), string.Empty, rootGroup);

            for (int i = 0; i < selectedPaths.Count; i++)
            {
                GUIGroupMenuItem          groupItem = selectedPaths[i];
                List <GUIGenericMenuItem> nestedGroup;

                string nextGroup = groupItem.Path;

                if (!string.IsNullOrEmpty(nextGroup))
                {
                    nextGroup += "/";
                }

                nextGroup += groupItem.Display.text;

                if (!groupedMenuItems.TryGetValue(nextGroup, out nestedGroup))
                {
                    continue;
                }

                Rect rect = DrawGroup(groupItem.PositionRect, nextGroup, nestedGroup);

                if (i == selectedPaths.Count - 1)
                {
                    deepestRect = rect;
                }
            }
        }