public void Awake() { if (Instance == null) { Instance = this; SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged; DontDestroyOnLoad(gameObject); } else { Destroy(this); } }
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); }; }