- Home /

# Issue with UV mapping a cube

Im trying to UV map this cube...

```
void GenerateTile (Coord coord) {
int baseIndex = (coord.z + coord.x * meshDepth + coord.y * meshWidth * meshDepth) * 36;
vertices [baseIndex] = new Vector3 (coord.x, coord.y, coord.z + 1);
vertices [baseIndex + 1] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
vertices [baseIndex + 2] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
vertices [baseIndex + 3] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
vertices [baseIndex + 4] = new Vector3 (coord.x, coord.y, coord.z);
vertices [baseIndex + 5] = new Vector3 (coord.x + 1, coord.y, coord.z);
vertices [baseIndex + 6] = new Vector3 (coord.x, coord.y + 1, coord.z);
vertices [baseIndex + 7] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
triangles [baseIndex] = triangles [baseIndex + 13] = triangles [baseIndex + 17] = triangles [baseIndex + 24] = baseIndex + 4;
triangles [baseIndex + 1] = triangles [baseIndex + 5] = triangles [baseIndex + 12] = triangles [baseIndex + 30] = baseIndex;
triangles [baseIndex + 2] = triangles [baseIndex + 4] = triangles [baseIndex + 20] = triangles [baseIndex + 22] = triangles [baseIndex + 25] = triangles [baseIndex + 29] = baseIndex + 6;
triangles [baseIndex + 3] = triangles [baseIndex + 18] = triangles [baseIndex + 32] = triangles [baseIndex + 34] = baseIndex + 2;
triangles [baseIndex + 6] = triangles [baseIndex + 14] = triangles [baseIndex + 16] = triangles [baseIndex + 31] = triangles [baseIndex + 35] = baseIndex + 1;
triangles [baseIndex + 8] = triangles [baseIndex + 10] = triangles [baseIndex + 19] = triangles [baseIndex + 23] = triangles [baseIndex + 33] = baseIndex + 3;
triangles [baseIndex + 7] = triangles [baseIndex + 11] = triangles [baseIndex + 15] = triangles [baseIndex + 26] = triangles [baseIndex + 28] = baseIndex + 5;
triangles [baseIndex + 9] = triangles [baseIndex + 21] = triangles [baseIndex + 27] = baseIndex + 7;
uvs [baseIndex] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 1] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 2] = new Vector2 (0, 1);
uvs [baseIndex + 3] = new Vector2 (0.0625f, 1);
uvs [baseIndex + 4] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 5] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 6] = new Vector2 (0, 1);
uvs [baseIndex + 7] = new Vector2 (0.0625f, 1);
uvs [baseIndex + 8] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 9] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 10] = new Vector2 (0, 1);
uvs [baseIndex + 11] = new Vector2 (0.0625f, 1);
uvs [baseIndex + 12] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 13] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 14] = new Vector2 (0, 1);
uvs [baseIndex + 15] = new Vector2 (0.0625f, 1);
uvs [baseIndex + 16] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 17] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 18] = new Vector2 (0, 1);
uvs [baseIndex + 19] = new Vector2 (0.0625f, 1);
uvs [baseIndex + 20] = new Vector2 (0, 0.9375f);
uvs [baseIndex + 21] = new Vector2 (0.0625f, 0.9375f);
uvs [baseIndex + 22] = new Vector2 (0, 1);
uvs [baseIndex + 23] = new Vector2 (0.0625f, 1);
}
```

However, since I didn't specify any vertices beyond 7, it doesnt work with uvs beyond 7. How can I fix this? I tried adding:

```
vertices [baseIndex + 8] = new Vector3 (coord.x, coord.y, coord.z + 1);
vertices [baseIndex + 9] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
vertices [baseIndex + 10] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
vertices [baseIndex + 11] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
vertices [baseIndex + 12] = new Vector3 (coord.x, coord.y, coord.z);
vertices [baseIndex + 13] = new Vector3 (coord.x + 1, coord.y, coord.z);
vertices [baseIndex + 14] = new Vector3 (coord.x, coord.y + 1, coord.z);
vertices [baseIndex + 15] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
vertices [baseIndex + 16] = new Vector3 (coord.x, coord.y, coord.z + 1);
vertices [baseIndex + 17] = new Vector3 (coord.x + 1, coord.y, coord.z + 1);
vertices [baseIndex + 18] = new Vector3 (coord.x, coord.y + 1, coord.z + 1);
vertices [baseIndex + 19] = new Vector3 (coord.x + 1, coord.y + 1, coord.z + 1);
vertices [baseIndex + 20] = new Vector3 (coord.x, coord.y, coord.z);
vertices [baseIndex + 21] = new Vector3 (coord.x + 1, coord.y, coord.z);
vertices [baseIndex + 22] = new Vector3 (coord.x, coord.y + 1, coord.z);
vertices [baseIndex + 23] = new Vector3 (coord.x + 1, coord.y + 1, coord.z);
```

**Answer** by tanoshimi
·
Feb 27, 2016 at 10:31 PM

"*since I didn't specify any vertices beyond 7, it doesnt work with uvs beyond 7*"

So why don't you add vertices beyond 7 then...? If you want "hard edges" and don't want to interpolate textures across faces (which it sounds like you don't), then they can't share vertices. So have 24 vertices, 24 uvs.

Becuause I've tried adding those vertices and it doesn't seem to work. I feel like this is one of those things where you need example code to learn. Could you pose some code?

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.