@@ -1108,7 +1108,6 @@ internal void SynchronizeSceneNetworkObjects(NetworkManager networkManager)
11081108 builder . AppendLine ( $ "[Read][Synchronize Objects][WPos: { InternalBuffer . Position } ][NO-Count: { newObjectsCount } ] Begin:") ;
11091109 }
11101110#if UNIFIED_NETCODE
1111- // TODO-UNIFIED: This is a temporary POC fix to handle hybrid spawning where the Ghost instance might not yet exist.
11121111 var spawnManager = m_NetworkManager . SpawnManager ;
11131112#endif
11141113
@@ -1119,7 +1118,10 @@ internal void SynchronizeSceneNetworkObjects(NetworkManager networkManager)
11191118 serializedObject . Deserialize ( InternalBuffer ) ;
11201119
11211120#if UNIFIED_NETCODE
1122- // TODO-UNIFIED: This is a temporary POC fix to handle synchronizing hybrid spawned objects where the Ghost instance might not yet exist.
1121+ // This handles the case where a NetworkObject is serialized with a ghost component but the ghost isn't actually included in
1122+ // the spawn message and won't be spawned by the client until later in the N4E synchronization process. In this case, we need
1123+ // to defer the deserialization of the NetworkObject until the ghost is spawned and we have an instance to deserialize this
1124+ // information during synchronization.
11231125 if ( serializedObject . HasGhost )
11241126 {
11251127 if ( ! networkManager . SpawnManager . GhostsPendingSpawn . ContainsKey ( serializedObject . NetworkObjectId ) )
@@ -1442,12 +1444,18 @@ internal SceneEventData(NetworkManager networkManager)
14421444 }
14431445
14441446#if UNIFIED_NETCODE
1447+ /// <summary>
1448+ /// Used to store pending ghost spawns that are waiting for their associated (N4E) ghost to be spawned before they can be fully deserialized and
1449+ /// spawned during the scene synchronization process. This is necessary because in unified mode we allow for NetworkObjects with ghost components
1450+ /// to be synchronized during the scene synchronization process but we can't guarantee the order of messages that the client receives so we
1451+ /// need to defer the deserialization of any NetworkObject that has a ghost component until we have received the message that the ghost has
1452+ /// been spawned and we have an instance to deserialize this information into.
1453+ /// </summary>
14451454 internal struct PendingGhostSpawnEntry
14461455 {
14471456 public float RegistrationTime ;
14481457 public FastBufferReader Buffer ;
14491458 public NetworkObject . SerializedObject SerializedObject ;
1450-
14511459 }
14521460#endif
14531461}
0 commit comments