diff --git a/Source/Engine/Networking/NetworkMessage.cs b/Source/Engine/Networking/NetworkMessage.cs index 6858ec722..db1e0eac3 100644 --- a/Source/Engine/Networking/NetworkMessage.cs +++ b/Source/Engine/Networking/NetworkMessage.cs @@ -275,6 +275,24 @@ namespace FlaxEngine.Networking return new string(bytes, 0, stringLength); } + /// + /// Writes data of type into the message. + /// + public void WriteGuid(Guid value) + { + WriteBytes((byte*)&value, sizeof(Guid)); + } + + /// + /// Reads and returns data of type from the message. + /// + public Guid ReadGuid() + { + var guidData = stackalloc Guid[1]; + ReadBytes((byte*)guidData, sizeof(Guid)); + return guidData[0]; + } + /// /// Writes data of type into the message. /// diff --git a/Source/Engine/Networking/NetworkMessage.h b/Source/Engine/Networking/NetworkMessage.h index e8196667d..217ee1361 100644 --- a/Source/Engine/Networking/NetworkMessage.h +++ b/Source/Engine/Networking/NetworkMessage.h @@ -201,6 +201,24 @@ public: ReadBytes((uint8*)value.Get(), length * sizeof(wchar_t)); return value; } + + /// + /// Writes data of type Guid into the message. + /// + FORCE_INLINE void WriteGuid(const Guid& value) + { + WriteBytes((uint8*)&value, sizeof(Guid)); + } + + /// + /// Reads and returns data of type Guid from the message. + /// + FORCE_INLINE Guid ReadGuid() + { + Guid value = Guid(); + ReadBytes((uint8*)&value, sizeof(Guid)); + return value; + } public: ///