# Problem when creating UVs coordinates

Hi everyone, I’m trying to learn how to create a mesh form scratch. I Created a C# script that render a block, but i got stuck in this part. When I hit play the mesh is rendered good, but the texture has a wrong rotation

Here the code:

``````using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CubeRender : MonoBehaviour {

protected List<Vector3> verts = new List<Vector3> ();
protected List<int> triangulos = new List<int> ();
protected List<Vector2> uvs = new List<Vector2> ();

private Mesh cubo;

private float uText = 0.25f;

void Start ()
{
cubo = GetComponent<MeshFilter> ().mesh;

float x = transform.position.x;
float z = transform.position.z;
float y = transform.position.y;

//Baixo
CriarFace (new Vector3(x, y, z), Vector3.forward, Vector3.right, true);

//Cima
CriarFace (new Vector3(x, y + 1, z), Vector3.forward, Vector3.right, false);

//Frente
CriarFace (new Vector3(x, y, z + 1), Vector3.up, Vector3.right, true);

//Tras
CriarFace (new Vector3(x, y, z), Vector3.up, Vector3.right, false);

//Esquerda
CriarFace (new Vector3(x, y, z), Vector3.up, Vector3.forward, true);

//Direita
CriarFace (new Vector3(x + 1, y, z ), Vector3.up, Vector3.forward, false);

cubo.Clear ();
cubo.vertices = verts.ToArray ();
cubo.triangles = triangulos.ToArray ();
cubo.uv = uvs.ToArray ();
cubo.Optimize ();
cubo.RecalculateNormals ();

}
void CriarFace(Vector3  origem, Vector3 direita, Vector3 cima, bool revertido)
{
int index = verts.Count;

verts.Add (origem + direita + cima);

if (invertido == true) {
}else{
}

}

void Update ()
{

}
}
``````

The rotation of top and bottom textures doesn’t matter, but the sides are wrong, the green part should be on the top.
Anyone has any idea of how I can solve this ?

Sorry about the awful explanation, and the horrible english :s

Simple way, this rotation of a texture on 90 degrees counterclockwise in any graphics editor. For example, in Photoshop. But it is possible to leave and so. But then it will be necessary to change textural coordinates. I change part of your code:

`````` void CriarFace(Vector3  origem, Vector3 direita, Vector3 cima, bool revertido) {
int index = verts.Count;

verts.Add (origem + direita + cima);

if (invertido == true) {
}else{