SurfaceTool AddUv not working as expected?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Staki

For fun I am attempting to make a minecraft style clone and in order to get the performance right I want to create large sections of blocks as a singular mesh. Being as they would have different textures I would combine the textures into a single texture sheet / atlas texture and then specify the proper UV coordinates to give the proper texture to that face of the mesh.

When I try to use SurfaceTool.AddUv instead of selecting coordinates in the UV, it appears to be scaling the entire UV. On a test texture sheet of 4 32x32 textures resulting in a 64x64 sheet passing UVs between Vector2(0,0) and Vector2(1,1) produces the entire texture sheet. I can isolate a single cell of the sheet by using Vector2(0,0) and Vector2(0.5,0.5), but being as it seems to be scaling it is impossible to isolate any other cells in the texture sheet.

Ideally I would have figured I could pass in the X,Y coordinates like such: AddUv(new Vector2(0,0)) to AddUV(new Vector2(32,32)), but this results in a scaled output and not a selection of a part of the UV. I haven’t dealt with UVs in code before so I realize I’m probably missing something or doing something wrong.

Image Example ( I realize the texture is being flipped from the resource. That is because I assigned the UVs in reverse order, but does not change the outcome described above ) :
enter image description here

:bust_in_silhouette: Reply From: Staki

Someone on reddit was able to answer this for me! I had a misunderstanding of how the UV coordinates were being set.