From 2971345f37e9337ff32a5d878dcb2d287fdd9786 Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 31 Dec 2019 09:26:13 +0100 Subject: [PATCH] NetworkManager.StartServer: scene change check moved into IsServerOnlineSceneChangeNeeded --- Assets/Mirror/Runtime/NetworkManager.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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); }