From a0c96f85189bfc9b5a936a8a33ebda34b460f17f Mon Sep 17 00:00:00 2001 From: MrGadget Date: Sat, 11 Jan 2020 18:12:46 -0500 Subject: [PATCH] fix: StopHost with offline scene calls scene change twice (#1409) * Separate StopHostClient * Added comments * move comment * add comment * Changed to loadingSceneAsync check * Update Assets/Mirror/Runtime/NetworkManager.cs Co-authored-by: vis2k --- Assets/Mirror/Runtime/NetworkManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 679606296..a06ecd317 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -613,7 +613,9 @@ public void StopClient() // doesn't think we need initialize anything. mode = NetworkManagerMode.Offline; - if (!string.IsNullOrEmpty(offlineScene) && SceneManager.GetActiveScene().name != offlineScene) + // If this is the host player, StopServer will already be changing scenes. + // Check loadingSceneAsync to ensure we don't double-invoke the scene change. + if (!string.IsNullOrEmpty(offlineScene) && SceneManager.GetActiveScene().name != offlineScene && loadingSceneAsync == null) { ClientChangeScene(offlineScene, SceneOperation.Normal); }