Skip to content

Commit

Permalink
fix: Don't call RegisterClientMessages every scene change (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGadget committed May 14, 2020
1 parent a245e37 commit 05c119f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions Assets/Mirror/Runtime/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,19 +995,14 @@ void FinishLoadSceneHost()
// call OnServerSceneChanged
OnServerSceneChanged(networkSceneName);

if (NetworkClient.isConnected)
{
RegisterClientMessages();

// DO NOT call OnClientSceneChanged here.
// the scene change happened because StartHost loaded the
// server's online scene. it has nothing to do with the client.
// this was not meant as a client scene load, so don't call it.
//
// otherwise AddPlayer would be called twice:
// -> once for client OnConnected
// -> once in OnClientSceneChanged
}
// DO NOT call OnClientSceneChanged here.
// the scene change happened because StartHost loaded the
// server's online scene. it has nothing to do with the client.
// this was not meant as a client scene load, so don't call it.
//
// otherwise AddPlayer would be called twice:
// -> once for client OnConnected
// -> once in OnClientSceneChanged
}
// otherwise we just changed a scene in host mode
else
Expand All @@ -1020,8 +1015,6 @@ void FinishLoadSceneHost()

if (NetworkClient.isConnected)
{
RegisterClientMessages();

// let client know that we changed scene
OnClientSceneChanged(NetworkClient.connection);
}
Expand Down

0 comments on commit 05c119f

Please sign in to comment.