using System; namespace Unity.Netcode { /// /// This is a wrapper that adds `INetworkSerializeByMemcpy` support to existing structs that the developer /// doesn't have the ability to modify (for example, external structs like `Guid`). /// /// public struct ForceNetworkSerializeByMemcpy : INetworkSerializeByMemcpy, IEquatable> where T : unmanaged, IEquatable { public T Value; public ForceNetworkSerializeByMemcpy(T value) { Value = value; } public static implicit operator T(ForceNetworkSerializeByMemcpy container) => container.Value; public static implicit operator ForceNetworkSerializeByMemcpy(T underlyingValue) => new ForceNetworkSerializeByMemcpy { Value = underlyingValue }; public bool Equals(ForceNetworkSerializeByMemcpy other) { return Value.Equals(other.Value); } public override bool Equals(object obj) { return obj is ForceNetworkSerializeByMemcpy other && Equals(other); } public override int GetHashCode() { return Value.GetHashCode(); } } }