fix: #3538 calling unspawn on scene objects in DestroyOwnedObjects (#3542)

* fix: calling unspawn on scene objects in DestroyOwnedObjects

fixes: https://github.com/MirrorNetworking/Mirror/issues/3538

* Update NetworkConnectionToClient.cs

---------

Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
This commit is contained in:
James Frowen 2023-07-06 08:59:28 +01:00 committed by GitHub
parent 51c7162af7
commit 08fa0269de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,6 +248,11 @@ internal void DestroyOwnedObjects()
{
if (netIdentity != null)
{
// unspawn scene objects, destroy instantiated objects.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3538
if (netIdentity.sceneId != 0)
NetworkServer.UnSpawn(netIdentity.gameObject);
else
NetworkServer.Destroy(netIdentity.gameObject);
}
}