Repository navigation
fix(serializing): write null for despawned NetworkObject references - #1078
Merged
FirstGearGames merged 1 commit intoOct 9, 2026
Merged
Conversation
FirstGearGames
pushed a commit
that referenced
this pull request
Oct 16, 2026
- Fixed prefab collection generator excluded folders not matching when saved on another platform or with a trailing slash (#1080). - Fixed SetLowestMTUs using the last channel's MTU instead of the lowest (#1101). - Fixed split message pieces being appended to non-empty buffers (#1079). - Fixed late-joining clients using the most recent global load's replace option instead of the last replacing load (#1035). - Fixed client prediction TimeManager.OnUpdate subscriptions stacking on pooled objects (#1075). - Fixed WriteInt64Unpacked writing a packed value instead of 8 bytes (#1072). - Fixed runtime parent not being set on clients for instantiated spawns (#1058). - Fixed instantiated spawns parented to a non-first NetworkBehaviour being placed under the wrong transform (#1058). - Fixed nested scene objects reparenting directly under their parent NetworkObject on clients (#1048). - Fixed runtime unparenting of scene objects not reaching clients (#1048). - Fixed obsolete Unity find and scripting-define calls behind version defines; compiles clean on Unity 6.6. - Fixed jagged arrays being rejected as multidimensional in codegen (#1105). - Fixed nullable arrays generating an open Nullable type in codegen (#1105). - Fixed clientHost scene object lookup for scenes loaded more than once (#1081). - Fixed despawned or pooled NetworkObjects not being written as a null reference (#1078). - Fixed NetworkCollision2D being commented out (#1074). - Fixed TimeManager rewriting the project's physics simulation mode and fixed delta time outside play mode (#1077). - Fixed network HUD canvas buttons being hidden when using the new input system (#1082). - Fixed OnDespawnServer not running for a connection removed by an observer rebuild while disconnecting (#1107). - Added level of detail to NetworkTransform. - Added TimeManager.NormalizedDeltaTime so OnUpdate movement covers the same distance every tick. - Added NetworkNavMeshAgent, synchronizing a NavMeshAgent.
FirstGearGames
pushed a commit
that referenced
this pull request
Oct 18, 2026
- Fixed prefab collection generator excluded folders not matching when saved on another platform or with a trailing slash (#1080). - Fixed SetLowestMTUs using the last channel's MTU instead of the lowest (#1101). - Fixed split message pieces being appended to non-empty buffers (#1079). - Fixed late-joining clients using the most recent global load's replace option instead of the last replacing load (#1035). - Fixed client prediction TimeManager.OnUpdate subscriptions stacking on pooled objects (#1075). - Fixed WriteInt64Unpacked writing a packed value instead of 8 bytes (#1072). - Fixed runtime parent not being set on clients for instantiated spawns (#1058). - Fixed instantiated spawns parented to a non-first NetworkBehaviour being placed under the wrong transform (#1058). - Fixed nested scene objects reparenting directly under their parent NetworkObject on clients (#1048). - Fixed runtime unparenting of scene objects not reaching clients (#1048). - Fixed obsolete Unity find and scripting-define calls behind version defines; compiles clean on Unity 6.6. - Fixed jagged arrays being rejected as multidimensional in codegen (#1105). - Fixed nullable arrays generating an open Nullable type in codegen (#1105). - Fixed clientHost scene object lookup for scenes loaded more than once (#1081). - Fixed despawned or pooled NetworkObjects not being written as a null reference (#1078). - Fixed NetworkCollision2D being commented out (#1074). - Fixed TimeManager rewriting the project's physics simulation mode and fixed delta time outside play mode (#1077). - Fixed network HUD canvas buttons being hidden when using the new input system (#1082). - Fixed OnDespawnServer not running for a connection removed by an observer rebuild while disconnecting (#1107). - Added level of detail to NetworkTransform. - Added TimeManager.NormalizedDeltaTime so OnUpdate movement covers the same distance every tick. - Added NetworkNavMeshAgent, synchronizing a NavMeshAgent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Writing a NetworkObject that had been despawned sent its PrefabId, so the
reader resolved the reference to the prefab asset instead of null. This
affected RPC parameters, SyncVars, broadcasts and any custom serializer,
through WriteNetworkObject, WriteNetworkBehaviour, WriteGameObject and
WriteTransform.
The receiver ends up holding the prefab asset where it should have
null, so code acting on that reference could end up operating on the prefab instead of an instance. This is easy to hit: despawn an object and pass it to an RPC or SyncVar in the same frame. Pooled objects are affected for as long as a stale reference is held, not just for that frame.Cause
Despawning sets IsDeinitializing, so IsSpawned becomes false while the
C# reference stays non-null. WriteNetworkObject took its "not spawned"
branch, which exists for prefab-template references, and wrote PrefabId.
Fix
NetworkManager is assigned when a NetworkObject initializes and is never
cleared by ResetState. If it is set, the object was spawned at some point
and is no longer valid, so a null reference is written instead. Prefab
assets and never-spawned instances still write their PrefabId.
Behavior change
A recycled pooled instance that has been fetched from
the pool but not yet spawned now serializes as null instead of the
prefab.