What is a difference between Mesh.uv and Mesh.SetUVs?

Hi, guys!
What is a difference between Mesh.uv and Mesh.SetUVs? I just notices that SetUVs alows to use a list of Vector2, Vector3, Vector4. And the Mesh also has the GetUVs method to get these lists.
I don’t get why it allows to use Vector3 and Vector4?

1 Like

SetUVs allows setting the channel, rather than referring to Mesh.uv, uv2, uv3, and uv4 separately, and you use Lists instead of arrays, plus you can use Vector3 and Vector4 as you note. Vector3/4 are only readable if you use GetUVs, since Mesh.uv etc. are Vector2 only. You can use UVW for shader stuff like 3D textures. Not sure about Vector4 (I guess that’s UVWX?), but also presumably used for more shader stuff.

–Eric

2 Likes

Thank you! Although I didn’t get about 4D texture coordinates. I read about the trapezoidal projection problem. But I could’t get this problem.

You dont have to use SetUVs just for uvs. Imagine shader’s TEXCOORDx more like a Vector4 which you can fill with any float values which you need to send from C# to shader per vertex. For example if you have multiple meshes with textures, which you want to MeshCombine, you can use the texcoord values to hold indices into texture array.