I doubt than anyone knows the vertex order from the top of his head. You could just try it out and change one vertex color at a time and write its index down if you need to know it. Note that you will need a material/shader which utilizes the vertex colors.
This is super unhelpfull. How is anyone supposed to give advise or help based on that? If you would specifiy how EXACTLY it does not work as you expect it, someone may have an idea. So give error messages, strange behavior, compiler warnings etc. . Just “doesnt work” helps nothing to help you improve it. When you tell what is wrong it greatly reduces the possible amount of bugs we need to look for, consider and explain. Most people won’t create a project and test the code for you to find out WHY it does not work. So if you want help be as clear, detailed and consise as possible. This SHOULD be obvious though.
I’m not expecting anyone to have memorised it. And I’ve already realised that I can go through it vertex by vertex until I have the solution. I hoped there would be a documentation somewhere that I could be pointed. to I have looked all over and the only thing I found that deals with this seems to be wrong, which is why what I coded fails to sort the verticies into surfaces. See below…
The reason it does not work is that it assumes an order to the vertices, based on the idea that they are used in an obvious linear sequence. I assumed vertices groupings for each surface of the cube like this:
In the answer to this rubik’s cube question on UA I’ve posted this example script which is a fully functioning rubik’s cube script. It just needs 27 default cubes as children. At the very end of the script I create a modified mesh based on the default cube mesh and assign a unique color to each side. The sides are distinguished by the normal vectors of each face.
Though usually it may be simpler to just create a custom cube mesh the way you need it. A cube is a quite simple shape. The default cube has the advantage that it already has UV coordinates. Though if you don’t need them creating a cube manually isn’t that difficult. Over here I’ve posted a script to create a mesh that represents the camera frustum. The camera frustum is essentially a distorted cube. For simplicity I first created the 8 logical corners and then split them up into 24 based on the VertOrder array. Without the for loop in line 33 / 34 the result would already be a cuboid. Though instead of the near and far clipplane at z you can use 0 and 1
If you really want to know, print them, Vector3 V=mesh.vertexes; and a simple loop. Or, for extra fun, make a Text3D prefab to spawn and place at each corner with a number. Unchecked:
public Text3D T3Dprefab; // should be centered both ways
void Start() {
Vector3[] V=GetComponent<MeshRenderer>().mesh.vertices;
for(int i=0; i<V.Length; i++) {
Text3D cornerT=Instantiate(T3Dprefab, V[i]);
cornerT.text=""+i;
}
}