Assuming your Vector3 type is a struct, and all of its members are blittable (which singles/floats are), you should be able to run them through the Marshal.

I’ve not tested it, but something along the lines of this should work:

{byte[] buffer = new byte[sizeof(Vector3)];fixed (byte* b = buffer)Marshal.StructureToPtr(new Vector3{X = 1, Y = 1, Z = 1}, new IntPtr((int)b), false);byte[] buff = new byte[sizeof(Vector3)];fixed(byte* b = buff)Unsafe.Write(b, new Vector3{X = 1, Y = 1, Z = 1});}struct Vector3{public float X;public float Y;public float Z;}

Where the Unsafe variant is much, much faster.

--

--

--

Software Engineer writing about his daily software adventures, wherever they may lead.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Martin Cerruti

Martin Cerruti

Software Engineer writing about his daily software adventures, wherever they may lead.

More from Medium

The ice is so thin, now it’s breaking.

8 actors who played two roles in one movie

pt. 1 moments of grief

So Much Intensity