private void OnActiveSceneChanged(Scene arg0, Scene arg1)
        {
            new GameObject().AddComponent <ObjectMover>();
            if (arg1.buildIndex != 2)
            {
                return;
            }
            SubMenu            twitchChatMenu  = SettingsUI.CreateSubMenu("Twitch Chat");
            BoolViewController twitchChatPanel = twitchChatMenu.AddBool("Twitch Chat Panel");

            twitchChatPanel.GetValue += delegate { return(chatPanel != null ? chatPanel.activeSelf : false); };
            twitchChatPanel.SetValue += delegate(bool value) { chatPanel?.SetActive(value); PlayerPrefs.SetInt("ChatActive", value ? 1 : 0); };
            BoolViewController twitchResponsePanel = twitchChatMenu.AddBool("Twitch Response Panel");

            twitchResponsePanel.GetValue += delegate { return(responsePanel != null ? responsePanel.activeSelf : false); };
            twitchResponsePanel.SetValue += delegate(bool value) { responsePanel?.SetActive(value); PlayerPrefs.SetInt("ResponsesActive", value ? 1 : 0); };
        }
Exemple #2
0
        public static SubMenu CreateSubMenu(string name)
        {
            if (!isMenuScene(SceneManager.GetActiveScene()))
            {
                Console.WriteLine("Cannot create settings menu when no in the main scene.");
                return(null);
            }

            if (tableCell == null)
            {
                tableCell = Resources.FindObjectsOfTypeAll <MainSettingsTableCell>().FirstOrDefault();
                // Get a refence to the Settings Table cell text in case we want to change fint size, etc
                var text = tableCell.GetPrivateField <TextMeshProUGUI>("_settingsSubMenuText");
            }

            var temp = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().FirstOrDefault();

            var       others = temp.transform.Find("Others");
            var       tweakSettingsObject = Instantiate(others.gameObject, others.transform.parent);
            Transform mainContainer       = CleanScreen(tweakSettingsObject.transform);

            var tweaksSubMenu = new SettingsSubMenuInfo();

            tweaksSubMenu.SetPrivateField("_menuName", name);
            tweaksSubMenu.SetPrivateField("_controller", tweakSettingsObject.GetComponent <VRUIViewController>());

            var mainSettingsMenu = Resources.FindObjectsOfTypeAll <MainSettingsMenuViewController>().FirstOrDefault();
            var subMenus         = mainSettingsMenu.GetPrivateField <SettingsSubMenuInfo[]>("_settingsSubMenuInfos").ToList();

            subMenus.Add(tweaksSubMenu);
            mainSettingsMenu.SetPrivateField("_settingsSubMenuInfos", subMenus.ToArray());

            SubMenu menu = new SubMenu(mainContainer);

            return(menu);
        }