CleanupNetworkIdentities: better comments and call DestroyObject with DestroyMode.Destroy for spawned prefabs directly. more obvious.

This commit is contained in:
vis2k 2021-07-31 17:10:49 +08:00
parent beff4b634a
commit 47bd2b7c78

View File

@ -129,21 +129,19 @@ static void CleanupNetworkIdentities()
{
if (identity != null)
{
// spawned scene objects are reset and disabled.
// they always stay in the scene, we don't destroy them.
// scene object
if (identity.sceneId != 0)
{
// spawned scene objects are only reset and disabled.
// they always stay in the scene, we don't destroy them.
identity.Reset();
identity.gameObject.SetActive(false);
}
// spawned prefabs are destroyed
// spawned prefabs
else
{
// call NetworkServer.Destroy directly instead of
// GameObject.Destroy()->
// NetworkIdentity.OnDestroy()->
// NetworkServer.Destroy()
Destroy(identity.gameObject);
// spawned prefabs are unspawned and destroyed.
DestroyObject(identity, DestroyMode.Destroy);
}
}
}