diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 4ff09b8db8..30c5cc9442 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -15,6 +15,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where internal delta serialization could not have a byte serializer defined when serializing deltas for other types. Added `[GenerateSerializationForType(typeof(byte))]` to both the `NetworkVariable` and `AnticipatedNetworkVariable` classes to assure a byte serializer is defined. (#2953) - Fixed issue with the client count not being correct on the host or server side when a client disconnects itself from a session. (#2941) - Fixed issue with the host trying to send itself a message that it has connected when first starting up. (#2941) - Fixed issue where in-scene placed NetworkObjects could be destroyed if a client disconnects early and/or before approval. (#2923) diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs index 2a08293206..eb8744f6a2 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs @@ -51,6 +51,7 @@ public enum StaleDataHandling #pragma warning restore IDE0001 [Serializable] [GenerateSerializationForGenericParameter(0)] + [GenerateSerializationForType(typeof(byte))] public class AnticipatedNetworkVariable : NetworkVariableBase { [SerializeField] diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs index a17b70333d..50d30987c6 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs @@ -9,6 +9,7 @@ namespace Unity.Netcode /// the unmanaged type for [Serializable] [GenerateSerializationForGenericParameter(0)] + [GenerateSerializationForType(typeof(byte))] public class NetworkVariable : NetworkVariableBase { /// diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs index c2d2d3e0a2..1f6d5529ad 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs @@ -717,7 +717,7 @@ public unsafe void WriteDelta(FastBufferWriter writer, ref T value, ref T previo writer.WriteValueSafe(value); return; } - writer.WriteByte(0); + writer.WriteByteSafe(0); BytePacker.WriteValuePacked(writer, value.Length); writer.WriteValueSafe(changes); unsafe @@ -766,7 +766,7 @@ public unsafe void ReadDelta(FastBufferReader reader, ref T value) { if (changes.IsSet(i)) { - reader.ReadByte(out ptr[i]); + reader.ReadByteSafe(out ptr[i]); } } }