Skip to content

Instantly share code, notes, and snippets.

@creativitRy
Created August 9, 2019 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativitRy/7cfba729d2d488085ecccfb82a33779f to your computer and use it in GitHub Desktop.
Save creativitRy/7cfba729d2d488085ecccfb82a33779f to your computer and use it in GitHub Desktop.
Entity UUID
[Serializable]
[StructLayout(LayoutKind.Explicit)]
public struct EntityUuid : IComparable, IComparable<EntityUuid>, IComparable<Guid>, IEquatable<EntityUuid>, IEquatable<Guid>
{
[SerializeField]
[FieldOffset(0)]
private long _firstHalf;
[SerializeField]
[FieldOffset(8)]
private long _secondHalf;
[FieldOffset(0)]
private readonly Guid _guid;
public EntityUuid(string explicitName)
{
if (explicitName == null)
{
CreateProceduralUuid();
}
else
{
CreateExplicitUuid(explicitName)
}
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment