Skip to content

Instantly share code, notes, and snippets.

@aevitas
Created March 10, 2020 14:49
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 aevitas/321dc150752ce109001b841a1755a2b7 to your computer and use it in GitHub Desktop.
Save aevitas/321dc150752ce109001b841a1755a2b7 to your computer and use it in GitHub Desktop.
public static unsafe byte[] GetVectorBytes(ref Vector3 vec)
{
Span<byte> buffer = stackalloc byte[sizeof(Vector3)];
fixed (byte* b = buffer)
Marshal.StructureToPtr(vec, new IntPtr(b), false);
return buffer.ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment