Skip to content

Commit

Permalink
fix(NetworkServer): Call NetworkClient.InvokeUnSpawnHandler from UnSp…
Browse files Browse the repository at this point in the history
…awnInternal

- Fixes #3962
There may be a custom unspawn handler for the prefab and NetworkClient::OnHostClientObjectDestroy doesn't invoke it and can't because it's already out of spawned dictionary.
  • Loading branch information
MrGadget1024 committed Dec 30, 2024
1 parent c4491c7 commit 6c2df9e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Assets/Mirror/Core/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,9 @@ static void UnSpawnInternal(GameObject obj, bool resetState)
// in host mode, call OnStopClient/OnStopLocalPlayer manually
if (NetworkClient.active && activeHost)
{
// custom unspawn handler for this prefab (for prefab pools etc.)
NetworkClient.InvokeUnSpawnHandler(identity.assetId, identity.gameObject);

if (identity.isLocalPlayer)
identity.OnStopLocalPlayer();

Expand Down

0 comments on commit 6c2df9e

Please sign in to comment.