Setting custom UV Mapping

Hey All,

I've created a procedural hexagon mesh and I'm trying to texture it. When I do apply a texture it is completed messed up. I'm sure it's because I'm not setting up a proper UV map for the mesh. The problem is I'm not exactly sure how to go about setting it up. I understand how I would do it for a cube, but I'm puzzled how to go about it for a hexagon.

Here's the code where I setup the mesh. Thanks for the help in advance.

public class HexTile : MonoBehaviour
{
    public float height = 0.5f;
    public float zWidth = 2;

    void Awake()
    {
        Mesh m = ((MeshFilter)gameObject.GetComponent("MeshFilter")).mesh;

        float angle = 360 / 6;     

        float b = zWidth / 2;
        float c = b / Mathf.Cos((Mathf.PI / 180) * (angle / 2));
        float a = b * Mathf.Tan((Mathf.PI / 180) * (angle / 2));        

        int[] pt = { 0,2,1, 0,3,2, 0,4,3, 0,5,4, 0,6,5, 0,1,6, //top
                 7,8,9, 7,9,10, 7,10,11, 7,11,12, 7,12,13, 7,13,8, //bottom
                 2,8,1, 2,9,8, //sides
                 3,9,2, 3,10,9,
                 4,10,3, 4,11,10,
                 5,11,4, 5,12,11,
                 6,12,5, 6,13,12,
                 1,13,6, 1,8,13};

        Vector3[] pv = new Vector3[14];

        //top face
        pv[0] = new Vector3(0, height, 0);
        pv[1] = new Vector3(c, height, 0);
        pv[2] = new Vector3(a, height, b);
        pv[3] = new Vector3(-a, height, b);
        pv[4] = new Vector3(-c, height, 0);
        pv[5] = new Vector3(-a, height, -b);
        pv[6] = new Vector3(a, height, -b);

        //bottom face
        pv[7] = new Vector3(0, 0, 0);
        pv[8] = new Vector3(c, 0, 0);
        pv[9] = new Vector3(a, 0, b);
        pv[10] = new Vector3(-a, 0, b);
        pv[11] = new Vector3(-c, 0, 0);
        pv[12] = new Vector3(-a, 0, -b);
        pv[13] = new Vector3(a, 0, -b);

        m.vertices = pv;
        m.triangles = pt;

        m.RecalculateNormals();
        m.RecalculateBounds();
   }
}

Add these codes after this two line.

m.vertices = pv;
m.triangles = pt;

int nVertices = m.vertices.Length;
Vector2 uvs = new Vector2[nVertices];
for(int i=0; i<nVertices; i++)
{
   uvs _= m.vertices*;*_

}
m.uvs = uvs;
Good luck!

http://unity3d.com/support/documentation/ScriptReference/Mesh-uv.html