From cb6a7812f50d43c7539b378607c0a360bfbf6b6d Mon Sep 17 00:00:00 2001 From: miwarnec Date: Wed, 6 Nov 2024 12:39:35 +0100 Subject: [PATCH] Vector3Half reader/writer --- Assets/Mirror/Core/NetworkReaderExtensions.cs | 7 +++++++ Assets/Mirror/Core/NetworkWriterExtensions.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Assets/Mirror/Core/NetworkReaderExtensions.cs b/Assets/Mirror/Core/NetworkReaderExtensions.cs index dd366f667..254aa3ec9 100644 --- a/Assets/Mirror/Core/NetworkReaderExtensions.cs +++ b/Assets/Mirror/Core/NetworkReaderExtensions.cs @@ -63,6 +63,13 @@ public static class NetworkReaderExtensions public static decimal? ReadDecimalNullable(this NetworkReader reader) => reader.ReadBlittableNullable(); public static Half ReadHalf(this NetworkReader reader) => new Half(reader.ReadUShort()); + public static Vector3Half ReadVector3Half(this NetworkReader reader) + { + Half x = reader.ReadHalf(); + Half y = reader.ReadHalf(); + Half z = reader.ReadHalf(); + return new Vector3Half(x, y, z); + } /// if an invalid utf8 string is sent public static string ReadString(this NetworkReader reader) diff --git a/Assets/Mirror/Core/NetworkWriterExtensions.cs b/Assets/Mirror/Core/NetworkWriterExtensions.cs index 1f6588f77..e74b3e8c6 100644 --- a/Assets/Mirror/Core/NetworkWriterExtensions.cs +++ b/Assets/Mirror/Core/NetworkWriterExtensions.cs @@ -58,6 +58,12 @@ public static class NetworkWriterExtensions public static void WriteDecimalNullable(this NetworkWriter writer, decimal? value) => writer.WriteBlittableNullable(value); public static void WriteHalf(this NetworkWriter writer, Half value) => writer.WriteUShort(value._value); + public static void WriteVector3Half(this NetworkWriter writer, Vector3Half value) + { + writer.WriteHalf(value.x); + writer.WriteHalf(value.y); + writer.WriteHalf(value.z); + } public static void WriteString(this NetworkWriter writer, string value) {