Obviously I don’t know how to use the UVs could someone help me out?
void RenderCell(Cell c, Vector3[] verts, int[] tris, Vector2[] uvs)
{
int x = c.x;
int y = c.y;
//floor
verts[vIndex++] = new Vector3(0+x, 0, 0-y);
verts[vIndex++] = new Vector3(0+x, 0, 1-y);
verts[vIndex++] = new Vector3(1+x, 0, 1-y);
verts[vIndex++] = new Vector3(1+x, 0, 0-y);
uvs[uIndex++] = new Vector2(0f, 0f);
uvs[uIndex++] = new Vector2(0f, 1f);
uvs[uIndex++] = new Vector2(1f, 1f);
uvs[uIndex++] = new Vector2(1f, 0f);
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 4;
if (c.CheckWall(Direction.North))
{
verts[vIndex++] = new Vector3(0+x, 0, 1-y);
verts[vIndex++] = new Vector3(0+x, 2, 1-y);
verts[vIndex++] = new Vector3(1+x, 2, 1-y);
verts[vIndex++] = new Vector3(1+x, 0, 1-y);
uvs[uIndex++] = new Vector2(0f, 0f);
uvs[uIndex++] = new Vector2(0f, 1f);
uvs[uIndex++] = new Vector2(1f, 1f);
uvs[uIndex++] = new Vector2(1f, 0f);
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 4;
}
if (c.CheckWall(Direction.East))
{
verts[vIndex++] = new Vector3(1+x, 0, 0-y);
verts[vIndex++] = new Vector3(1+x, 2, 0-y);
verts[vIndex++] = new Vector3(1+x, 2, 1-y);
verts[vIndex++] = new Vector3(1+x, 0, 1-y);
uvs[uIndex++] = new Vector2(0f, 0f);
uvs[uIndex++] = new Vector2(0f, 1f);
uvs[uIndex++] = new Vector2(1f, 1f);
uvs[uIndex++] = new Vector2(1f, 0f);
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 4;
}
if (c.CheckWall(Direction.South))
{
verts[vIndex++] = new Vector3(0+x, 0, 0-y);
verts[vIndex++] = new Vector3(0+x, 2, 0-y);
verts[vIndex++] = new Vector3(1+x, 2, 0-y);
verts[vIndex++] = new Vector3(1+x, 0, 0-y);
uvs[uIndex++] = new Vector2(0f, 0f);
uvs[uIndex++] = new Vector2(0f, 1f);
uvs[uIndex++] = new Vector2(1f, 1f);
uvs[uIndex++] = new Vector2(1f, 0f);
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 4;
}
if (c.CheckWall(Direction.West))
{
verts[vIndex++] = new Vector3(0+x, 0, 0-y);
verts[vIndex++] = new Vector3(0+x, 2, 0-y);
verts[vIndex++] = new Vector3(0+x, 2, 1-y);
verts[vIndex++] = new Vector3(0+x, 0, 1-y);
uvs[uIndex++] = new Vector2(0f, 0f);
uvs[uIndex++] = new Vector2(0f, 1f);
uvs[uIndex++] = new Vector2(1f, 1f);
uvs[uIndex++] = new Vector2(1f, 0f);
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 3;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 4;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 2;
tris[tIndex++] = vIndex - 1;
tris[tIndex++] = vIndex - 4;
}
}