Skip to content

Instantly share code, notes, and snippets.

@TheFizz
Created November 25, 2019 23:42
Show Gist options
  • Save TheFizz/d56a3c2627086ed852464f5087e526c3 to your computer and use it in GitHub Desktop.
Save TheFizz/d56a3c2627086ed852464f5087e526c3 to your computer and use it in GitHub Desktop.
float segmentAngle;
segmentAngle = 360f / segments;
float partialSegmentAngle = segmentAngle / angleFraction;
float currentRotation = segmentAngle;
for (int i = 0; i < segments; i++)
{
Mesh mesh = new Mesh();
Vector3[] vertices = new Vector3[angleFraction + 2];
vertices[0] = Vector3.zero;
for (int j = 0; j < angleFraction + 1; j++)
{
int curPoint = i * angleFraction + j;
if (curPoint <= points.Count - 1)
vertices[j + 1] = points[curPoint];
else
vertices[j + 1] = points[0];
}
Vector2[] uvs = new Vector2[vertices.Length];
for(int j = 0; j< vertices.Length;j++)
{
uvs[j] = new Vector2(Mathf.Repeat(vertices[j].x, 1), Mathf.Repeat(vertices[j].y, 1));
}
mesh.vertices = vertices;
int[] tris = new int[angleFraction * 3];
for (int k = 0; k < angleFraction; k++)
{
tris[k * 3] = 0;
tris[k * 3 + 1] = k + 1;
tris[k * 3 + 2] = k + 2;
}
mesh.uv = uvs;
mesh.triangles = tris;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment