internal static void ShowMenu(MenuTree menuTree, CentrifugeMenu parentMenu, int pageIndex)
        {
            if (menuTree.GetItems().Count is 0)
            {
                ShowUnavailableMessage();
                return;
            }

            foreach (var component in parentMenu.PanelObject_.GetComponents <CentrifugeMenu>())
            {
                component.Destroy();
            }

            var menu = GameAPI.Instance.gameObject.AddComponent <CentrifugeMenu>();

            menu.MenuTree = menuTree;

            menu.CurrentPageIndex             = pageIndex;
            menu.MenuPanel                    = MenuPanel.Create(menu.PanelObject_, true, true, false, true, true, true);
            menu.MenuPanel.backgroundOpacity_ = 0.75f;

            menu.MenuPanel.onIsTopChanged_ += (isTop) =>
            {
                if (isTop)
                {
                    menu.ResetAnimations();
                }
                else
                {
                    if (G.Sys.MenuPanelManager_.panelStack_.Contains(menu.MenuPanel))
                    {
                        menu.SwitchPage(menu.CurrentPageIndex, false, true);
                    }
                    else
                    {
                        menu.SwitchPage(0, false, true);
                    }
                }
            };

            menu.MenuPanel.onPanelPop_ += () =>
            {
                if (!G.Sys.MenuPanelManager_.panelStack_.Contains(menu.MenuPanel))
                {
                    menu.SwitchPage(0, false, true);
                    parentMenu.PanelObject_.SetActive(true);

                    if (menu.MenuTree != MenuTree)
                    {
                        menu.PanelObject_.Destroy();
                    }

                    menu.Destroy();
                }
            };

            parentMenu.PanelObject_.SetActive(false);

            menu.MenuPanel.Push();
        }
Beispiel #2
0
        public static void OpenComponentSelectMenu(this global::LevelEditor _, string headerText, Action <HierarchyComponentData> pathCallback, MenuPanel.OnPanelPop onPopCallback)
        {
            G.Sys.MenuPanelManager_.Clear(true);
            componentSelectMenuLogic.Show(headerText, pathCallback);
            MenuPanel menuPanel = MenuPanel.Create(componentSelectMenuLogic.gameObject, false, false, false, true, false, false);

            menuPanel.onPanelPop_      = onPopCallback;
            menuPanel.allowZeroPanels_ = true;
            menuPanel.showBforBack_    = false;
            menuPanel.Push();
        }