Why doesn't my combined mesh look how it supposed to do?

I have a script that generates all necessary quads and it works fine. The picture below shows the separate quads before combining:


After that i’m combining everything with this function:

void combineQuads()
    MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
    CombineInstance[] combine = new CombineInstance[meshFilters.Length];
    for (int i = 0; i < meshFilters.Length; i++)
        combine_.mesh = meshFilters*.sharedMesh;*_

combine_.transform = meshFilters*.transform.localToWorldMatrix;

MeshFilter mf = (MeshFilter)this.gameObject.AddComponent(typeof(MeshFilter));
mf.mesh = new Mesh();

MeshRenderer renderer = this.gameObject.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
renderer.material = material;

foreach (Transform quad in this.transform)
And then i get this:
Why does this happen? If i generate a way smaller chunk everything is working fine but the larger ones are glitching. It confuses me.


I suspect you are simply exceeding the maximum number of vertices for a mesh.

You will need to make a few meshes, rather than just one.