Drawing a cube by a new Mesh

Hi guys, I am with a very simple problem, but it is blocking my work. I am instantiating a cube with a new Mesh, setting manually all the vertices, uv’s, triangles and normals.
This is my code:

using UnityEngine;
using System.Collections;

public class cube : MonoBehaviour {
	public Vector3 index;
	void Start(){
		mesh.Clear();
		mesh.vertices = new Vector3[] {new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 1, 0), new Vector3(1, 0, 0),  //front
									   new Vector3(1, 0, 1), new Vector3(1, 1, 1), new Vector3(0, 1, 1), new Vector3(0, 0, 1),  //back
									   new Vector3(1, 0, 0), new Vector3(1, 1, 0), new Vector3(1, 1, 1), new Vector3(1, 0, 1),  //right
									   new Vector3(0, 0, 1), new Vector3(0, 1, 1), new Vector3(0, 1, 0), new Vector3(0, 0, 0),  //left
									   new Vector3(0, 1, 0), new Vector3(0, 1, 1), new Vector3(1, 1, 1), new Vector3(1, 1, 0),  //top
									   new Vector3(0, 0, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 1), new Vector3(1, 0, 0)}; //bottom
		mesh.uv = new Vector2[] {new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0),
								 new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0),
								 new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0),
								 new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0),
								 new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0),
								 new Vector2(0, 0),    new Vector2(0, 1),    new Vector2(1, 1),    new Vector2 (1, 0)};
		mesh.triangles = new int[] {0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23};
		mesh.normals = new Vector3[] {new Vector3( 0, 0,-1),new Vector3( 0, 0,-1),new Vector3( 0, 0,-1),new Vector3( 0, 0,-1),  //front
									  new Vector3( 0, 0, 1),new Vector3( 0, 0, 1),new Vector3( 0, 0, 1),new Vector3( 0, 0, 1),  //back
									  new Vector3( 1, 0, 0),new Vector3( 1, 0, 0),new Vector3( 1, 0, 0),new Vector3( 1, 0, 0),  //right
									  new Vector3(-1, 0, 0),new Vector3(-1, 0, 0),new Vector3(-1, 0, 0),new Vector3(-1, 0, 0),  //left
									  new Vector3( 0, 1, 0),new Vector3( 0, 1, 0),new Vector3( 0, 1, 0),new Vector3( 0, 1, 0),  //top
									  new Vector3( 0,-1, 0),new Vector3( 0,-1, 0),new Vector3( 0,-1, 0),new Vector3( 0,-1, 0)}; //bottom
	}
}

The problem is: the bottom face normals are inverted, and i can’t invert them.
This is the cube made by this code, with the normals drawn on Gizmos.

[7235-sem+título.png|7235]

The normals settings are correct. This is the same cube, with only the bottom face drawn.

[7237-sem+título2.png|7237]

Then the normals are really bugged, not simply inverted. In the image1, the bottom normals are settled like the posted code. The image2 is the bottom normals with the inverted normals.

I don’t know why it’s happening. Please help me!! thanks!

It seems like the problem is your triangle is generated facing the wrong way. Normals are mainly used to calculate light, but the triangles are what decide whether something faces one way or the other. Try changing 20,21,22 and 20,22,23 to 20,22,21 and 20,23,22

Sounds like the perfect time to bring out my freshly made wiki entry : http://wiki.unity3d.com/index.php/ProceduralPrimitives