unity vector3 to array 1

unity vector3 to array

Vector3 vector = new Vector3(0,1,0);
// Convert to float array
floats[] toFloat = new float[]{vector.x,vector.y,vector.z};
// Back to vector
vector = new Vector3 (toFloat[1], toFloat[2], toFloat[3]);

Here is what the above code is Doing:
1. Create a new Vector3 object with the values 0,1,0
2. Create a new float array with the values of the Vector3 object
3. Create a new Vector3 object with the values of the float array

Similar Posts