Skip to content

Commit

Permalink
fix: Cleaning up network objects when server stops (#1864)
Browse files Browse the repository at this point in the history
* destroying or disabling network objects when server stops

* adding clear after loop

* Update Assets/Mirror/Runtime/NetworkManager.cs

Co-authored-by: MrGadget <chris@clevertech.net>

* Update Assets/Mirror/Runtime/NetworkManager.cs

Co-authored-by: MrGadget <chris@clevertech.net>

* Update Assets/Mirror/Runtime/NetworkManager.cs

Co-authored-by: MrGadget <chris@clevertech.net>
  • Loading branch information
James-Frowen and MrGadget committed May 9, 2020
1 parent b4511a0 commit 4c25122
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Assets/Mirror/Runtime/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,20 @@ void RegisterClientMessages()

void CleanupNetworkIdentities()
{
foreach (NetworkIdentity identity in Resources.FindObjectsOfTypeAll<NetworkIdentity>())
foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values)
{
identity.Reset();
if (identity.sceneId != 0)
{
identity.Reset();
identity.gameObject.SetActive(false);
}
else
{
Destroy(identity.gameObject);
}
}

NetworkIdentity.spawned.Clear();
}

/// <summary>
Expand Down

0 comments on commit 4c25122

Please sign in to comment.