# code generated cube uv map for each sub mesh

so i have built a cube using code (rather then spawning in from 3d modelling like maya or using the primitives unity has)

i understand how to actually set the uvs

1 2,6 5
0 3,7 4
< these correspond to the vertices as if you saw them on a uv map i.e 0 = new vector(0,0) << first one in array the numbers show where they are in the uv map.

``````BUvs = new Vector2[8] {
new Vector2(0,0),new Vector2(0,1),
new Vector2(0.5f,1),new Vector2(0.5f,0),
new Vector2(1,1),new Vector2(1,0),
new Vector2(0.5f,0),new Vector2(0.5f,1)
};
``````

anyway the textures… look… ok i guess but realistically

is there a way to assign submeshes to different uv sets?

i.e each face on the cube is a sub mesh with its own texture but if i could assign front and back face to a uv and right and left to uv2 so on then it would make it look a lot better

As weird as it may sound, you actually need 24 vertices to make a cube. That’s because uvs and normals are vertex attributes: the normals are different for each face, and the uvs are also different in many vertices. The normals are the worst case: each face must have its own 4 vertices, thus you need 6 x 4 vertices in order to accomodate all the different normals.