From b8cc7a87a4d2a587241619c34577763b583a9db8 Mon Sep 17 00:00:00 2001 From: Jared Chavez Date: Thu, 9 Nov 2023 16:43:04 -0800 Subject: [PATCH 1/2] proposed fix for issue-542 - in 4.0.1 the WriteSpawn_Server function in ManagedObjects.Spawning.cs was changed to use WriteNetworkBehaviourId instead of WriteNetworkObjectId. This appends a new byte of data (component index) to the data stream, but the corresponding read was not updated to do the same. This ends up causing parse errors on the client side during spawn events for nested NetworkObjects in certain conditions (specifically, if the nested NetworkObjects' immediate parent is a plain GameObject being used for organizational purposes --- .../FishNet/Runtime/Managing/Client/Object/ClientObjects.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs b/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs index 4e8bee7f6..39131e686 100644 --- a/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs +++ b/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs @@ -724,7 +724,9 @@ private void ReadSpawnedObject(PooledReader reader, out int? parentObjectId, out } } - prefabId = (ushort)reader.ReadNetworkObjectId(); + // componentIndex is currently unused + _ = reader.ReadNetworkBehaviourId(out var nobId); + prefabId = (ushort)nobId; } } From 8321e7c48084f8e33e5b66e5ca56e374b9a05ff2 Mon Sep 17 00:00:00 2001 From: Jared Chavez Date: Thu, 9 Nov 2023 17:01:59 -0800 Subject: [PATCH 2/2] revert to previous release behavior --- .../FishNet/Runtime/Managing/Client/Object/ClientObjects.cs | 4 +--- .../Runtime/Managing/Object/ManagedObjects.Spawning.cs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs b/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs index 39131e686..4e8bee7f6 100644 --- a/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs +++ b/Assets/FishNet/Runtime/Managing/Client/Object/ClientObjects.cs @@ -724,9 +724,7 @@ private void ReadSpawnedObject(PooledReader reader, out int? parentObjectId, out } } - // componentIndex is currently unused - _ = reader.ReadNetworkBehaviourId(out var nobId); - prefabId = (ushort)nobId; + prefabId = (ushort)reader.ReadNetworkObjectId(); } } diff --git a/Assets/FishNet/Runtime/Managing/Object/ManagedObjects.Spawning.cs b/Assets/FishNet/Runtime/Managing/Object/ManagedObjects.Spawning.cs index ee5a8e865..3a18209f3 100644 --- a/Assets/FishNet/Runtime/Managing/Object/ManagedObjects.Spawning.cs +++ b/Assets/FishNet/Runtime/Managing/Object/ManagedObjects.Spawning.cs @@ -96,7 +96,7 @@ internal void WriteSpawn_Server(NetworkObject nob, NetworkConnection connection, * on the other end. This is problematic because the object which is parent * may not be spawned yet. Clients handle caching potentially not yet spawned * objects via Ids. */ - headerWriter.WriteNetworkBehaviourId(nob.CurrentParentNetworkBehaviour); + headerWriter.WriteNetworkObjectId(nob.CurrentParentNetworkBehaviour.ObjectId); } /* Writing a scene object. */ if (sceneObject)