mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkManager.StartServer: scene change check moved into IsServerOnlineSceneChangeNeeded
This commit is contained in:
parent
39817fcf00
commit
2971345f37
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This starts a new server.
|
||||
/// <para>This uses the networkPort property as the listen port.</para>
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user