Figuring out UVs for a circle mesh created by code

I’m trying to generate a circular mesh made up of triangles with a common center at the center of the circle.

I want the UVs to point outward, so that a moving shader applied to this will seem like it’s flowing from the center to the edges.
This already happens naturally on the sphere primitive, but I only need a flat surface without an underside.


I use this code to generate the mesh.
I thought the UV points would be similar to the vertexes, but I’m not getting any good results.

private void _MakeMesh(int sides, float radius = 0.5f)
float angleStep = 360.0f / (float) sides;
List<Vector3> vertexes      = new List<Vector3>();
List<int>       triangles   = new List<int>();
List<Vector2>   uvs         = new List<Vector2>();
Quaternion      rotation  = Quaternion.Euler(0.0f, angleStep, 0.0f);

// Make first triangle.
vertexes.Add(new Vector3(0.0f, 0.0f, 0.0f));  
vertexes.Add(new Vector3(radius, 0.0f, 0.0f));    
vertexes.Add(rotation * vertexes[1]);        

// First UV ??
uvs.Add(new Vector2(0, 0));
uvs.Add(new Vector2(1, 0));
uvs.Add(rotation * uvs[1]);

// Add triangle indices.
for (int i = 0; i < sides - 1; i++)
    triangles.Add(vertexes.Count - 1);

    // UV ??

    vertexes.Add(rotation * vertexes[vertexes.Count - 1]);
m_LiquidMesh.vertices   = vertexes.ToArray();
m_LiquidMesh.triangles  = triangles.ToArray();
m_LiquidMesh.uv         = uvs.ToArray();


Please, where am I going wrong with this?

This is an old post, but maybe someone else will benefit from my solution.

So basically I gave my center point the center of the uv (0.5, 0.5) and then used the used circle formula to give every other point the uv coordinate. But of course I had to remap the cos and sin results from -1…1 to 0…1 and everything is working great.

    Vector2[] uv = new Vector2[vertices.Length];
	uv[uv.Length - 1] = new Vector2(0.5f, 0.5f);

	for (int i = 0; i < uv.Length - 1; i++)
		float radians = (float) i / (uv.Length - 1) * 2 * Mathf.PI;
		uv *= new Vector2(Mathf.Cos(radians).Remap(-1f, 1f, 0f, 1f), Mathf.Sin(radians).Remap(-1f, 1f, 0f, 1f));*
  •   }*
  •   mesh.uv = uv;*

Where the remap is an extension like this and it basically take a value in a range and remaps it to another range (in this case from -1…1 to 0…1):

  • public static float Remap(this float value, float from1, float to1, float from2, float to2) {*
    _ return (value - from1) / (to1 - from1) * (to2 - from2) + from2;_
  • }*