MeshGenerationContext renders mesh upside down

References

I used this to create a square version of the radial progress bar. However, when rendering the square, the UI renders it flipped vertically.

I noticed the author worked around this issue by starting at -180 and working backwards.

I used the mesh generator to visualize and debug the vertices and it appears that my vertices and indices are correct. I can get it to work as expected, however when applying the same mesh generation on the UIElement, everything is flipped.

This is my first time generating meshes and working with triangles, I learned a lot doing this exercise but I feel like I must be missing something else that isn’t explicitly explained. I verified my vertices start at the top and work clockwise. What am I missing? Please help me understand so I can put this behind me.

Here is a rextester to see the vertices and indices

Here is a git upload of the code used
https://github.com/boydbuchanan/UnityRadialProgressMeshBuilder

Ui meshes are in screen space (0;0 is top left) while 3d meshes (like the one used for the gameObject Mesh Component have the y facing up, so 0 is at the bottom.

These meshes are interpreted slightly differently, be sure to specify the z value to
Vertex.nearZ when building vertices for UI Toolkit.

Instead of building vertices by hand, I can suggest using the MeshGenerationContext.painter2D API that uses higher level concept to build the geometry.

The correct link for painter2d would have been : Unity - Scripting API: Painter2D

and using it you would get automatic tessellation of the shape/ends of the line with “infinite precision” of arc