- Home /
Primitive Cube Vertices Different
I've been working on UV mapping within Unity for a project I'm working on and I found and used the script found here: http://answers.unity3d.com/questions/306959/uv-mapping.html
Now this works perfectly fine on Windows, but when I try and do the exact same thing on my Mac, things don't work right, the texture on the sides of the cube get split 'incorrectly'.
In this code:
private Vector2[] theUVs;
void Start()
{
theMesh = transform.GetComponent<MeshFilter>().mesh;
theUVs = new Vector2[theMesh.uv.Length];
theUVs = theMesh.uv;
SetUVs();
}
the array 'theUVs' has the same values in PC vs Mac. But in the mac version I get:
I can fix it here:
// OLD: LEFT 19 17 16 18
//theUVs[19] = new Vector2( uvsLeft.x, uvsLeft.y );
//theUVs[17] = new Vector2( uvsLeft.x + uvsLeft.width, uvsLeft.y );
//theUVs[16] = new Vector2( uvsLeft.x, uvsLeft.y - uvsLeft.height );
//theUVs[18] = new Vector2( uvsLeft.x + uvsLeft.width, uvsLeft.y - uvsLeft.height );
// LEFT 19 17 16 18
theUVs[17] = new Vector2( uvsLeft.x, uvsLeft.y );
theUVs[18] = new Vector2( uvsLeft.x + uvsLeft.width, uvsLeft.y );
theUVs[16] = new Vector2( uvsLeft.x, uvsLeft.y - uvsLeft.height );
theUVs[19] = new Vector2( uvsLeft.x + uvsLeft.width, uvsLeft.y - uvsLeft.height );
The question really is, why is it different between the two systems? Why do I have to change it?
Thanks for your help
Answer by FortisVenaliter · Jan 27, 2016 at 08:18 PM
You're probably using DirectX on Windows, and OpenGL on Mac. They use opposite winding orders for rendering. I think Unity fixes that for you if you import a mesh, but if you generate it dynamically, you may need to manage it yourself.