# uv coordinates of primitive cube

I am trying to manually edit the uvs of a primitive cube at runtime. I went through some trial and error to see if I could work it out but I cant. I need to know which out of the 24 uvs correspond to which points on the model. Are the uvs defined for example triangle by triangle, and if so, what order are the triangles in?

So through outputting the relevant arrays and some trial and error, I have an answer to this question. The vertices are defined in the following order:

``````(0.5, -0.5, 0.5)
(-0.5, -0.5, 0.5)
(0.5, 0.5, 0.5)
(-0.5, 0.5, 0.5)
(0.5, 0.5, -0.5)
(-0.5, 0.5, -0.5)
(0.5, -0.5, -0.5)
(-0.5, -0.5, -0.5)
(0.5, 0.5, 0.5)
(-0.5, 0.5, 0.5)
(0.5, 0.5, -0.5)
(-0.5, 0.5, -0.5)
(0.5, -0.5, -0.5)
(-0.5, -0.5, 0.5)
(-0.5, -0.5, -0.5)
(0.5, -0.5, 0.5)
(-0.5, -0.5, 0.5)
(-0.5, 0.5, -0.5)
(-0.5, -0.5, -0.5)
(-0.5, 0.5, 0.5)
(0.5, -0.5, -0.5)
(0.5, 0.5, 0.5)
(0.5, -0.5, 0.5)
(0.5, 0.5, -0.5)

``````

and the faces (viewed from above) are made from two triangles each as follows:

north 1 0 3

3 0 2

up 9 8 5

5 8 4

south 11 10 7

7 10 6

down 14 12 13

13 12 15

west 18 16 17

17 16 19

east 22 20 21

21 20 23

The UVs correspond to the vertices. (So do the normals, tangents, and colors.) As for what order they're in, that depends on the model.

i created a simple script, which show UV positions and order

``````using UnityEditor;
using System.Collections;
using UnityEngine;

[CustomEditor(typeof(CubeAtlasUVController))]
class LableHandle : Editor {
void OnSceneGUI () {
Handles.BeginGUI();
Handles.color = Color.blue;

CubeAtlasUVController cubeController=(CubeAtlasUVController)target;

Mesh mesh = cubeController.gameObject.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
int i = 0;
while (i < vertices.Length) {
Vector3 position=vertices_*(1+i*0.05f);_
``````
• `````` Handles.Label(position,"["+i+"]");*
``````

i++;
}

• `````` Handles.EndGUI();*
``````

}
}
So result of execution is the following picture in the editor (also i have a gizmo, but this is from another script)
[3981-screen+shot+2012-10-07+at+10.46.48+am.png|3981]*
*