Skip to content

Commit

Permalink
fix: calling NetworkReset with custom unspawn handlers
Browse files Browse the repository at this point in the history
NetworkReset is needed so that object can be re-used by user later.
  • Loading branch information
James-Frowen committed Jul 5, 2023
1 parent d6ced44 commit 94a9199
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Assets/Mirage/Runtime/ClientObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ private void UnSpawn(NetworkIdentity identity)
if (_handlers.TryGetValue(identity.PrefabHash, out var handler) && handler.UnspawnHandler != null)
{
handler.UnspawnHandler.Invoke(identity);
// need to call reset incase user puts object in pool and wants to re-use it later
// it needs to be dont after the handler so user still has access to network fields while cleaning it up
identity.NetworkReset();
}
else if (!identity.IsSceneObject)
{
Expand Down

0 comments on commit 94a9199

Please sign in to comment.