From 32320014664a779684e92acd47d48444ac103cdb Mon Sep 17 00:00:00 2001 From: vis2k Date: Sat, 31 Jul 2021 20:17:55 +0800 Subject: [PATCH] NetworkServer.DestroyObject: added comments --- Assets/Mirror/Runtime/NetworkServer.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 030acaf3b..b6e59437b 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -1228,18 +1228,17 @@ static void DestroyObject(NetworkIdentity identity, DestroyMode mode) identity.connectionToClient?.RemoveOwnedObject(identity); - ObjectDestroyMessage message = new ObjectDestroyMessage - { - netId = identity.netId - }; - SendToObservers(identity, message); - + // send object destroy message to all observers, clear observers + SendToObservers(identity, new ObjectDestroyMessage{netId = identity.netId}); identity.ClearObservers(); + + // in host mode, call OnStopClient manually if (NetworkClient.active && localClientActive) { identity.OnStopClient(); } + // we are on the server. call OnStopServer. identity.OnStopServer(); // are we supposed to GameObject.Destroy() it completely?