I’m making a bunch of meshes based on a set of 2d coordinates and an extrusion modifier. The shape creation is working well (mostly, but that’s another question), but I’m having trouble with normals/uvs. As you can see from this image, the lighting is very odd. I’ve followed [this tutorial][1], but still end up with this odd lighting. Any suggestions?

[16399-messedupcolors.jpg*_|16399]

The code specific to UV:

```
//Create the UV map. Nothing special here, copied and pasted.
Vector2[] uvs = new Vector2[AllVerts.Length];
for (int i=0; i<uvs.Length; i++) {
uvs <em>= new Vector2(AllVerts_.x, AllVerts*.z);*_</em>
```

** }**

** newMesh.uv = uvs;**

** newMesh.triangles = NewTriangles;**

** newMesh.RecalculateNormals();**

*The entire function:*

** //Given a name, list of points, and a depth, return a procedurally generated shape.**

** GameObject CreateObject(string name, List points, float depth){**

** if(depth < 0){ //TODO: Swap this into something that moves the plane down, or reverses triangles or vertices, for negatives**

** depth = Mathf.Abs(depth);**

** }**

** GameObject newObject = new GameObject(name);**

** newObject.AddComponent();**

** newObject.AddComponent();**

** Mesh newMesh = new Mesh();**

** int howManyVerts = points.Count; //Count the number of verts on a flat surface**

*_ Vector3 AllVerts = new Vector3[howManyVerts * 2]; //Twice as many verst as on a flab surface_*

** List TriangleList = new List(); //Gotta put all of the triangles somewhere - defined by the index of 3 verts in AllVerts**

** for(int i = 0; i < howManyVerts; i++){**

* AllVerts = new Vector3(points_.x, 0, points*.y); //Convert points to Vector3**

*AllVerts[i+howManyVerts] = new Vector3(points*.x, depth, points*.y); //Replaces with depth*_** if(i < howManyVerts-1){**

** //First triangle**

** TriangleList.Add (i+howManyVerts);**

** TriangleList.Add (i+1);**

** TriangleList.Add (i);**

** //Second triangle**

** TriangleList.Add (i+howManyVerts+1);**

** TriangleList.Add (i+1);**

** TriangleList.Add (i+howManyVerts);**

** }**

** else{//For the final piece of wall**

** //First triangle**

** TriangleList.Add (i+howManyVerts);**

** TriangleList.Add (0);**

** TriangleList.Add (i);**

** //Second triangle**

** TriangleList.Add (i+howManyVerts);**

** TriangleList.Add (howManyVerts);**

** TriangleList.Add (0);**

** }**

** }**

** //Create data for caps**

** Vector2[] TopCapVertices= new Vector2[howManyVerts];**

** for(int i = 0; i<howManyVerts; i++){**

* TopCapVertices = points*;**

** }**** Triangulator tr = new Triangulator(TopCapVertices);**

** int[] indices = tr.Triangulate();**

** int[] NewTriangles = new int[TriangleList.Count + indices.Length];**

** //Add triangles from TriangleList**

** for(int i = 0; i<TriangleList.Count; i++){**

* NewTriangles = TriangleList*;**

** }**

** //Add triangles from the Triangulator**

** for(int i = 0; i<indices.Length; i++){**

*_ NewTriangles[i+TriangleList.Count] = indices*+howManyVerts;**}*_*** newMesh.vertices = AllVerts;**

** //Create the UV map. Nothing special here, copied and pasted.**

** Vector2[] uvs = new Vector2[AllVerts.Length];**

** for (int i=0; i<uvs.Length; i++) {**

* uvs = new Vector2(AllVerts_.x, AllVerts*.z);*

*}*_*** newMesh.uv = uvs;**

** newMesh.triangles = NewTriangles;**

** newMesh.RecalculateNormals();**

** newObject.GetComponent().mesh = newMesh; **

** newObject.AddComponent();**

** //ADD MATERIAL**

** Material defaultMaterial = new Material(Shader.Find (“Diffuse”));**

** defaultMaterial.color = Color.blue;**

** newObject.renderer.material = defaultMaterial;**

** return newObject;**

** }**

**[1]: http://games.deozaan.com/unity/MeshTutorial.pdf*_*

***