title: Creating a plane in unity, triangles don't look right
body: <p>I'm creating a plane using C# in unity and I've gotten it "working" I get a plane. However the triangles don't seem to be connecting correctly, and I can't work out why.</p>
  
  <p><img src="https://i.stack.imgur.com/JKNHe.png" alt=""></p>
  
  <p>As you can see by that picture, it explains it better than I can.</p>
  
  <p>I believe the issue is just with my indices, though I'm not sure.</p>
  
  <p>I think there may also be one triangle that isn't there also, so I think my array is to small for some reason also.</p>
  
  <pre><code>Mesh CreatePlane(int width, int depth)
  {
      Mesh m = new Mesh();
      int numVert=(width+1)*(depth+1);
      Vector3[] vertecies = new Vector3[numVert];
      Vector2[] uvs = new Vector2[numVert];
      int[] triangles = new int[width*depth*6];
  
      float uvx = 1.0f/width;
      float uvy = 1.0f/depth;
      int index = 0;
  
  
      for (int i = 0;i&lt;width;i++)
      {
          for(int j = 0;j&lt;depth;j++)
          {
              vertecies[index] = new Vector3(i,0,-j);
              uvs[index++] = new Vector2(j*uvx,i*uvy);
  
          }
      }
  
      index = 0;
      for(int j=0; j&lt;depth; j++)
      {
          for(int i=0; i&lt;width; i++)
          {
  
              triangles[index++] = (j * (width+1)) + i;
              triangles[index++] = ((j+1) * (width+1)) + i;
              triangles[index++] = (j * (width+1)) + i + 1;
  
              triangles[index++] = ((j+1) * (width+1)) + i;
              triangles[index++] = ((j+1) * (width+1)) + i + 1;
              triangles[index++] = (j * (width+1)) + i + 1;
  
          }
      }
  
      m.name = "ScriptPlane";
      m.vertices = vertecies;
      m.uv = uvs;
      m.triangles = triangles;
      m.RecalculateNormals();
  
      return m;
  }
  </code></pre>