I want to convert a float array to a byte array to send it via socket to a python script. (Im doing this in the Unity engine).
I tried:
float[] myArray = {0.0f, 0.0f, 0.0f};
int len = myArray.Length;
byte[] bytes = new byte[len];
int x = 0;
foreach(float f in bytes){
byte[] t = System.BitConverter.GetBytes(f);
for(int y = 0; y<4); y++){
bytes[y + x] = t[y];
x += 4;
}
}
The output is this:
Assets\PlayerScript.cs(106,27): error CS1002: ; expected
Assets\PlayerScript.cs(106,33): error CS1002: ; expected
Assets\PlayerScript.cs(106,33): error CS1513: } expected
Im not used to work with c# and cant get it to work... I also looked at some other stackoverflow code but that didnt really help.
)aftery<4