From 65ceddedf440a6803e08aa42e04777e01bb33a7d Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 23 Oct 2023 15:36:44 -0500 Subject: [PATCH 1/3] fix truncate buffer back to the position. --- com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index e0d0f21bef..27ada4b3b6 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -993,6 +993,8 @@ internal bool Synchronize(ref BufferSerializer serializer, ulong targetCli if (finalPosition == positionBeforeSynchronize || threwException) { writer.Seek(positionBeforeWrite); + + writer.Truncate(); return false; } else From ff4a6de79d6f269cb5071bfea137c820603746d0 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 23 Oct 2023 15:37:03 -0500 Subject: [PATCH 2/3] style adding comment --- com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index 27ada4b3b6..7a5bd73b32 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -993,7 +993,7 @@ internal bool Synchronize(ref BufferSerializer serializer, ulong targetCli if (finalPosition == positionBeforeSynchronize || threwException) { writer.Seek(positionBeforeWrite); - + // Truncate back to the size before writer.Truncate(); return false; } From 087f65c13a8bdbb0d158844cc6d858364618e79c Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 23 Oct 2023 15:43:11 -0500 Subject: [PATCH 3/3] update adding change log entry --- com.unity.netcode.gameobjects/CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index a1a96bf5ba..7f8c954aa6 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -6,7 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). -## [Unreleased] +### Added + + +### Fixed + +- Fixed issue where `NetworkBehaviour.Synchronize` was not truncating the write buffer if nothing was serialized during `NetworkBehaviour.OnSynchronize` causing an additional 6 bytes to be written per `NetworkBehaviour` component instance. (#2749) + +### Changed + + +## [1.7.0] ### Added