public void OnQuitButtonPressed(string sceneName = "MainMenu") { // reset global state // PacketPoolManager.inst.CleanUpStatics(); ScoreManager.inst.packetMetrics.Clear(); Destination.CleanUpStatics(); SharedPlayer.playerIdForThisDevice = -1; NetworkManagerHLAPI.reset(); inst.players.Clear(); inst.syncEvents.Clear(); Destroy(inst); Destroy(LobbyMenuManager.inst); foreach (BarchartManager barchats in BarchartManager.insts) { Destroy(barchats); } BarchartManager.insts.Clear(); Destroy(DismissableScreenManager.inst); // possilby redundant and wet code if (NetworkManager.singleton != null) { NetworkManager.singleton.StopClient(); NetworkManager.singleton.StopHost(); NetworkManager.singleton.StopServer(); NetworkManager.singleton.StopAllCoroutines(); Destroy(NetworkManager.singleton); } Time.timeScale = 1; if (MainMenu.isMultiplayerSelectedFromMenu) { inst.syncEvents.Add(new SyncEvent(MessageTypes.SET_NETWORK_STATE, ((int)SharedGameStates.OFFLINE).ToString())); inst.syncEvents.Add(new SyncEvent(MessageTypes.FORCE_GAME_SHUTDOWN, "")); SceneManager.LoadScene(sceneName); } else { SceneManager.LoadScene(sceneName); } }