diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 754ca92b5..801f0c726 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -265,6 +265,14 @@ public virtual void LateUpdate() #region Start & Stop + // keep the online scene change check in a separate function + bool IsServerOnlineSceneChangeNeeded() + { + // Only change scene if the requested online scene is not blank, and is not already loaded + string loadedSceneName = SceneManager.GetActiveScene().name; + return !string.IsNullOrEmpty(onlineScene) && onlineScene != loadedSceneName && onlineScene != offlineScene; + } + /// /// This starts a new server. /// This uses the networkPort property as the listen port. @@ -307,9 +315,8 @@ public bool StartServer() if (LogFilter.Debug) Debug.Log("NetworkManager StartServer"); isNetworkActive = true; - // Only change scene if the requested online scene is not blank, and is not already loaded - string loadedSceneName = SceneManager.GetActiveScene().name; - if (!string.IsNullOrEmpty(onlineScene) && onlineScene != loadedSceneName && onlineScene != offlineScene) + // scene change needed? + if (IsServerOnlineSceneChangeNeeded()) { ServerChangeScene(onlineScene); }