Skip to content

Commit

Permalink
Vector3Half reader/writer
Browse files Browse the repository at this point in the history
  • Loading branch information
miwarnec committed Nov 7, 2024
1 parent c36feeb commit cb6a781
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Assets/Mirror/Core/NetworkReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public static class NetworkReaderExtensions
public static decimal? ReadDecimalNullable(this NetworkReader reader) => reader.ReadBlittableNullable<decimal>();

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);
}

/// <exception cref="T:System.ArgumentException">if an invalid utf8 string is sent</exception>
public static string ReadString(this NetworkReader reader)
Expand Down
6 changes: 6 additions & 0 deletions Assets/Mirror/Core/NetworkWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit cb6a781

Please sign in to comment.