Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public struct Vec3f
- {
- public float x, y, z;
- // ...
- public unsafe static explicit operator byte[](Vec3f s)
- {
- var bts = new byte[12];
- var ps = &s;
- var btsp = (byte*) ps;
- for (var i = 0; i < 12; i++)
- bts[i] = btsp[i];
- return bts;
- }
- public unsafe static explicit operator Vec3f(byte[] bts)
- {
- fixed (byte* btsp = &bts[0])
- {
- return *(Vec3f*)btsp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement