diff --git a/Assets/FishNet/Runtime/Serializing/Writer.cs b/Assets/FishNet/Runtime/Serializing/Writer.cs index 19f5d7ab..14a17905 100644 --- a/Assets/FishNet/Runtime/Serializing/Writer.cs +++ b/Assets/FishNet/Runtime/Serializing/Writer.cs @@ -967,6 +967,17 @@ public void WriteNetworkObject(NetworkObject nob) return; } + /* NetworkManager is assigned when a NetworkObject initializes + * and is never cleared by ResetState, so if it is set this object + * was previously spawned and is now despawning/despawned (or pooled). + * Send a null reference rather than falling back to PrefabId, which + * the reader would resolve to the prefab template instead of null. */ + if (nob.NetworkManager != null) + { + WriteNullReferenceId(); + return; + } + WriteNetworkObjectId(nob.PrefabId); } else