Search Unity

Shader wants texture coordinates, but the mesh doesn't have them

Discussion in 'Scripting' started by Dazzid, Sep 23, 2014.

  1. Dazzid

    Dazzid

    Joined:
    Apr 15, 2014
    Posts:
    61
    Hi,
    I'm trying to resolve this problem about Tangent for the shader, In his code I also add tangent, but don't get the solution.
    What should I do to fix it?

    Code (CSharp):
    1.  
    2. privatevoidAddLine (Meshm, Vector3[] quad, booltmp)
    3.  {
    4. int vl = m.vertices.Length;
    5.                 Vector3[] vs = m.vertices;
    6.                 Vector2[] uvs = new Vector2[vs.Length];
    7.                 int i = 0;
    8.                 while (i < uvs.Length) {
    9.                         uvs [i] = new Vector2 (vs [i].x, vs [i].z);
    10.                         i++;
    11.                 }
    12.                
    13.        
    14.                 if (!tmp || vl == 0)
    15.                         vs = resizeVertices (vs, 4);
    16.                 else
    17.                         vl -= 4;
    18.        
    19.                 vs [vl] = quad [0];
    20.                 vs [vl + 1] = quad [1];
    21.                 vs [vl + 2] = quad [2];
    22.                 vs [vl + 3] = quad [3];
    23.        
    24.                 int tl = m.triangles.Length;
    25.        
    26.                 int[] ts = m.triangles;
    27.                 if (!tmp || tl == 0)
    28.                         ts = resizeTraingles (ts, 6);
    29.                 else
    30.                         tl -= 6;
    31.                 ts [tl] = vl;
    32.                 ts [tl + 1] = vl + 1;
    33.                 ts [tl + 2] = vl + 2;
    34.                 ts [tl + 3] = vl + 1;
    35.                 ts [tl + 4] = vl + 3;
    36.                 ts [tl + 5] = vl + 2;
    37.  
    38.                 m.vertices = vs;
    39.                 m.uv = uvs;
    40.                 m.triangles = ts;
    41.                 m.RecalculateNormals();
    42.                 m.RecalculateBounds ();
    43. }
    44.