Hi there’s my code :
void Start()
{
Mesh mesh = new Mesh();
for(int y = 0; y < 2; y++)
{
Vector3[] vertices = new Vector3[4];
vertices[0] = new Vector3(0,0+y*ff,0); //top-left
vertices[1] = new Vector3(10,0+y*ff,0); //top-right
vertices[2] = new Vector3(0,-10+y*ff,0); //bottom-left
vertices[3] = new Vector3(10,-10+y*ff,0); //bottom-right
mesh.vertices = vertices;
}
int[] triangles = new int[12]{0,1,2,1,3,2 ,2,3,4,3,5,4};
mesh.triangles = triangles;
Vector2[] uvs = new Vector2[4];
uvs[0] = new Vector2(0,1); //top-left
uvs[1] = new Vector2(1,1); //top-right
uvs[2] = new Vector2(0,0); //bottom-left
uvs[3] = new Vector2(1,0); //bottom-right
mesh.uv = uvs;
Vector3[] normals = new Vector3[4]{Vector3.forward,Vector3.forward,Vector3.forward,Vector3.forward};
mesh.normals = normals;
MeshFilter filter = GetComponent<MeshFilter>();
filter.mesh = mesh;
}
I’m trying draw 2 square plane but i have error with indices for the 2nd square:
"Some indices are referencing out of bounds vertices"
Im trying many combinations with “int triangles = new int[12]{0,1,2,1,3,2 ,2,3,4,3,5,4};” but nothing works. There’s no problem with drawing one square “int triangles = new int[6]{0,1,2,1,3,2};” then one square have texture and the 2nd was invisible but have transform arrows located at the center of this square.
Please for answer