FinishLoadScene uses new NetworkManager.mode. This way the host connection doesn't need to be connected before changing host server's online scene. This makes everything easier.

This commit is contained in:
vis2k 2020-01-06 12:34:39 +01:00
commit 3eb11c9a2d

View File

@ -502,8 +502,7 @@ public virtual void StartHost()
// is called after the server is actually properly started. // is called after the server is actually properly started.
OnStartHost(); OnStartHost();
// ConnectHost needs to be called BEFORE server changes scene. // TODO move this into FinishStartHost! (and test if it still works)
// otherwise FinishLoadScene doesn't know that we are in host mode.
// //
// ConnectHost needs to be called BEFORE SpawnObjects: // ConnectHost needs to be called BEFORE SpawnObjects:
// https://github.com/vis2k/Mirror/pull/1249/ // https://github.com/vis2k/Mirror/pull/1249/
@ -915,17 +914,17 @@ void FinishLoadScene()
Transport.activeTransport.enabled = true; Transport.activeTransport.enabled = true;
// host mode? // host mode?
if (NetworkClient.active && NetworkServer.active) if (mode == NetworkManagerMode.Host)
{ {
FinishLoadSceneHost(); FinishLoadSceneHost();
} }
// server-only mode? // server-only mode?
else if (NetworkServer.active) else if (mode == NetworkManagerMode.ServerOnly)
{ {
FinishLoadSceneServerOnly(); FinishLoadSceneServerOnly();
} }
// client-only mode? // client-only mode?
else if (NetworkClient.active) else if (mode == NetworkManagerMode.ClientOnly)
{ {
FinishLoadSceneClientOnly(); FinishLoadSceneClientOnly();
} }