Esempio n. 1
0
        public DebugUiButton AddSubMenu(
            DebugUiSubMenu subMenu,
            Direction subMenuDirection = Direction.Down)
        {
            subMenu._parent              = this;
            subMenu.enabled              = false;
            subMenu.color                = this.color;
            subMenu.textColor            = this.textColor;
            subMenu.pointerDownColor     = this.pointerDownColor;
            subMenu.pointerDownTextColor = this.pointerDownTextColor;
            var button = new DebugUiButton(subMenu.name, _itemWidth, _itemHeight);

            button.color                = this.color;
            button.textColor            = this.textColor;
            button.pointerDownColor     = this.pointerDownColor;
            button.pointerDownTextColor = this.pointerDownTextColor;
            button.onClick              = () =>
            {
                // サブメニューを閉じる
                bool opened = subMenu.enabled;
                CloseSub();
                if (!opened)
                {
                    subMenu.enabled = true;
                }
            };
            Add(button);
            Add(subMenu);
            Item item;

            item.button        = button;
            item.menu          = subMenu;
            item.menuDirection = subMenuDirection;
            _items.Add(item);
            Layout();
            return(button);
        }
Esempio n. 2
0
        public bool ToParent()
        {
            var ret    = false;
            var parent = _activeMenu.parent;

            if (parent != null)
            {
                parent.CloseSub();
                int newIndex = 0;
                for (int i = 0; i < parent.itemCount; i++)
                {
                    var item = parent.GetItem(i);
                    if (item.menu == _activeMenu)                     // 見つかったらその番号に戻す
                    {
                        newIndex = i;
                        break;
                    }
                }
                _activeMenu  = parent;
                _activeIndex = newIndex;
                ret          = true;
            }
            return(ret);
        }