CURRENT:
Example of what im trying to do:
Mesh CreateMesh(int num)
{
nodePositions = new Vector3[transform.childCount];
for (int i = 0; i < nodePositions.Length; i++)
nodePositions[i] = transform.GetChild(i).localPosition;
int x; //Counter
//Create a new mesh
Mesh mesh = new Mesh();
//Vertices
var vertex = new Vector3[nodePositions.Length];
for (x = 0; x < nodePositions.Length; x++)
{
vertex[x] = nodePositions[x];
}
//UVs
var uvs = new Vector2[vertex.Length];
for (x = 0; x < vertex.Length; x++)
{
if ((x % 2) == 0)
{
uvs[x] = new Vector2(0, 0);
}
else
{
uvs[x] = new Vector2(1, 1);
}
}
//Triangles
var tris = new int[3 * (vertex.Length - 2)]; //3 verts per triangle * num triangles
int C1, C2, C3;
if (num == 0)
{
C1 = 0;
C2 = 1;
C3 = 2;
for (x = 0; x < tris.Length; x += 3)
{
tris[x] = C1;
tris[x + 1] = C2;
tris[x + 2] = C3;
C2++;
C3++;
}
}
else
{
C1 = 0;
C2 = vertex.Length - 1;
C3 = vertex.Length - 2;
for (x = 0; x < tris.Length; x += 3)
{
tris[x] = C1;
tris[x + 1] = C2;
tris[x + 2] = C3;
C2--;
C3--;
}
}
//Assign data to mesh
mesh.vertices = vertex;
mesh.uv = uvs;
mesh.triangles = tris;
//Recalculations
mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();
//Name the mesh
mesh.name = "MyMesh";
//Return the mesh
return mesh;
}