public static SubMenu CreateSubMenu(string name)
        {
            lock (Instance) {
                Instance.SetupUI();

                var       subMenuGameObject = Instantiate(Instance.othersSubmenu.gameObject, Instance.othersSubmenu.transform.parent);
                Transform mainContainer     = CleanScreen(subMenuGameObject.transform);

                var newSubMenuInfo = new SettingsSubMenuInfo();
                newSubMenuInfo.SetPrivateField("_menuName", name);
                newSubMenuInfo.SetPrivateField("_viewController", subMenuGameObject.GetComponent <VRUIViewController>());

                var subMenuInfos = Instance.mainSettingsMenu.GetPrivateField <SettingsSubMenuInfo[]>("_settingsSubMenuInfos").ToList();
                subMenuInfos.Add(newSubMenuInfo);
                Instance.mainSettingsMenu.SetPrivateField("_settingsSubMenuInfos", subMenuInfos.ToArray());

                SubMenu menu = new SubMenu(mainContainer);
                return(menu);
            }
        }
        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);
        }
 public SubMenu AddSubMenu(string text, string hintText, SubMenu subMenu)
 {
     return(AddSubMenu_Internal(text, hintText, false, subMenu));
 }