+1 vote
by
List<Vector3> verts = new List<Vector3>();
for(int y = 0; y < 1001; y++)
{
for (int x = 0; x < 1001; x++)
{
verts.Add(new Vector3(x, 0f, y));
}
}
List<int> tris = new List<int>();
for(int y = 0; y < 1000; y++)
{
for (int x = 0; x < 1000; x++)
{
tris.Add((y * 1001) + x);
tris.Add(((y + 1) * 1001) + x);
tris.Add((y * 1001) + x + 1);
tris.Add(((y + 1) * 1001) + x);
tris.Add(((y + 1) * 1001) + x + 1);
tris.Add((y * 1001) + x + 1);
}
}
var mf = one.GetComponent<MeshFilter>();
mf.mesh.vertices = verts.ToArray();
mf.mesh.triangles = tris.ToArray();
mf.mesh.RecalculateBounds();

1 Answer

0 votes
by
 
Best answer
In Unity, due to the architecture of the engine (and hardware), the limit on the number of points is 65534 for ONE mesh. So your script creates points while it can.

Split the plane into more meshes during the creation process.
...