Normal problem

Ok so i created a cube procedurally and im not to sure how to map the uv’s as im new to uv mapping procedurally, Anyway i got this proble even when i use recalculateBound(); so could you guys tell me whats wrong, thanks,

Image:

Code :

using UnityEngine;
using System.Collections;

public class BlockDirt : MonoBehaviour{

	Block block;

	public void Start(){

		block = new Block();
		block.setBlockName("test");

		blockCreate(this.transform.position);

		Vector3 prevPos = this.transform.position;

		this.gameObject.AddComponent<MeshFilter>().mesh=blockCreate(this.transform.position);
		this.gameObject.AddComponent<MeshRenderer>();
		//this.gameObject.GetComponent<MeshRenderer>().materials[0] = (Material)Resources.Load("Textures/Blocks/BlockMat");
		
		this.transform.position=prevPos;

		Debug.Log("test");
	}

	public Mesh blockCreate(Vector3 pos){

		Mesh mesh = new Mesh();

		int scale = 2;

		Vector3[] verts = new Vector3[8];
		Vector2[] uvs = new Vector2[8];
		int[] tris;

		verts[0]=pos+new Vector3(0,0,0);
		verts[1]=pos+new Vector3(scale,0,0);
		verts[2]=pos+new Vector3(scale,0,scale);
		verts[3]=pos+new Vector3(0,0,scale);
		verts[4]=pos+new Vector3(0,scale,0);
		verts[5]=pos+new Vector3(scale,scale,0);
		verts[6]=pos+new Vector3(scale,scale,scale);
		verts[7]=pos+new Vector3(0,scale,scale);

		tris=new int[]{0,1,2,
			0,3,2,
			4,5,6,
			4,7,6,
			0,4,1,
			4,5,1,
			3,7,6,
			3,2,6,
			0,3,4,
			3,4,7,
			1,5,6,
			1,2,6

		};

		uvs[0]=new Vector2(1,0);
		uvs[1]=new Vector2(0.125f,0);
		uvs[2]=new Vector2(0,0.125f);
		uvs[3]=new Vector2(0.125f,0.125f);
		
		mesh.vertices = verts;
		mesh.triangles = tris;


		mesh.RecalculateNormals();

		mesh.uv = uvs;
		mesh.RecalculateBounds();
		return mesh;

	}
}

this isn’t a normal problem… its just the way you are “wrapping” your triangles…you need to wrap them the same way around other wise you get triangles that are backwards. triangles are basically groups of vertices which of course always come in 3. now the mesh “draw” them bases on the index of vertices your provide… so if you say 1,12,901 the render will draw lines between vertices 1, 12 and 901 to make a face(triangle).

for example

1 - 2
| \ |
3 - 4

those are my vertices… to wrap my triangles starting from 1 i would go 1,2,4 and 1,4,3. NOT 1,2,4 and 1,3,4. Triangles usually follow a “Clockwise” rule to ensure they face the correct way.

this documentation stipulates the importance of the order of vertices when making triangles

also found this… its not specific to Unity but has loads of info on mesh generation