Skip to content

Commit

Permalink
fix: stopping DestroyAllClientObjects being called in host mode.
Browse files Browse the repository at this point in the history
Client should not be destroying in host mode because it will also destory the server object
  • Loading branch information
James-Frowen committed Apr 11, 2022
1 parent f331875 commit 582c20b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Assets/Mirage/Runtime/ClientObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ void UnSpawn(NetworkIdentity identity)
/// </summary>
public void DestroyAllClientObjects()
{
// dont destroy objects if we are server
if (Client.IsLocalClient)
{
if (logger.LogEnabled()) logger.Log("Skipping DestroyAllClientObjects because we are host client");
return;
}

// create copy so they can be removed inside loop
// allocation here are fine because is part of clean up
NetworkIdentity[] all = Client.World.SpawnedIdentities.ToArray();
Expand Down

0 comments on commit 582c20b

Please sign in to comment.