Esempio n. 1
0
        private SubMenu AddSubMenu_Internal(string text, string hintText, bool addBackButton, SubMenu subMenu = null)
        {
            if (viewController == null)
            {
                throw new Exception("You cannot add a submenu using this method outside of the settings menu.");
            }

            if (subMenu == null)
            {
                _subSubMenus.TryGetValue(text, out subMenu);
                if (subMenu == null)
                {
                    subMenu            = SettingsUI.CreateSubMenu(text, false);
                    _subSubMenus[text] = subMenu;
                    if (addBackButton)
                    {
                        subMenu.AddSubMenu("Back", "Go back to the previous menu", this);
                    }
                }
            }

            GameObject gameObj = new GameObject("CustomUIText");

            gameObj.SetActive(false);

            ClickableText clickableText = gameObj.AddComponent <ClickableText>();

            clickableText.font = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(t => t.name == "Teko-Medium SDF No Glow"));
            clickableText.rectTransform.SetParent(transform, false);
            clickableText.text     = text;
            clickableText.fontSize = 5;
            clickableText.color    = Color.white;

            clickableText.rectTransform.anchorMin = new Vector2(0f, -3);
            clickableText.rectTransform.anchorMax = new Vector2(0f, -3);
            //clickableText.rectTransform.anchoredPosition = new Vector2(0f, -1f);

            clickableText.OnClickEvent += (eventData) => {
                var settingsFlowCoordinator = Resources.FindObjectsOfTypeAll <SettingsFlowCoordinator>().FirstOrDefault();
                if (settingsFlowCoordinator)
                {
                    var navigationController = settingsFlowCoordinator.GetPrivateField <SettingsNavigationController>("_settingsNavigationController");
                    settingsFlowCoordinator.InvokePrivateMethod("PopViewControllerFromNavigationController", new object[] { navigationController, null, true });
                    settingsFlowCoordinator.InvokePrivateMethod("PushViewControllerToNavigationController", new object[] { navigationController, subMenu.viewController, null, true });
                }
            };

            gameObj.SetActive(true);

            if (hintText != String.Empty)
            {
                BeatSaberUI.AddHintText(clickableText.rectTransform, hintText);
            }

            viewController?.AddSubmenuOption(clickableText.gameObject);
            return(subMenu);
        }
Esempio n. 2
0
 public void SceneManagerOnActiveSceneChanged(Scene from, Scene to)
 {
     if (to.name == "EmptyTransition")
     {
         if (Instance)
         {
             Destroy(Instance.gameObject);
         }
         initialized = false;
         Instance    = null;
     }
 }