#Why is my triangle not being generated?

1 messages · Page 1 of 1 (latest)

untold jewel
#

Here is the code:

private IEnumerator Generate()
    {
        WaitForSeconds wait = new WaitForSeconds(0.01f);

        GetComponent<MeshFilter>().mesh = mesh = new Mesh();
        mesh.name = "Proceduarl Mesh";

        vertices = new Vector3[(xSize + 1) * (ySize + 1)];
        for (int i = 0, y = 0; y <= ySize; y++)
        {
            for (int x = 0; x <= xSize; x++, i++)
            {
                vertices[i] = new Vector3(x, y);
                yield return wait;
            }
        }

        mesh.vertices = vertices;

        int[] triangles = new int[3];
        triangles[0] = 0;
        triangles[1] = xSize + 1;
        triangles[2] = 1;

        mesh.triangles = triangles;

    }

#

I don't think it's anything wrong with the code but maybe with the rendering or URP or something cuz I copy and pasted another working script and it didn't show me either