Combine meshes without moving them?

When I used the combine meshes script (Unity - Scripting API: Mesh.CombineMeshes) it moves the meshes. I’ve read to try moving to parent to 0,0,0 1st or multiply each child mesh localToWorldMatrix with the parent’s worldToLocalMatrix, but neither of those fix the issue. I’ve pasted the code below as an example. Does anyone know how to combine a bunch of child meshes without them being moved?

        Vector3 tempPos = gameObject.transform.position;
        gameObject.transform.position =;


        MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
        CombineInstance[] combine = new CombineInstance[meshFilters.Length];

        Material mat = null;
        Matrix4x4 pMat = gameObject.transform.worldToLocalMatrix;
        for (int i = 0;  i < meshFilters.Length; i++)
            mat = meshFilters*.GetComponent<MeshRenderer>().material;*

combine_.mesh = meshFilters*.sharedMesh;
combine.transform = pMat * meshFilters.transform.localToWorldMatrix;_


transform.GetComponent().mesh = new Mesh();
gameObject.GetComponent().material = mat;

gameObject.transform.position = tempPos;

You could parent the meshes to one mesh.

I think I figured out the issue. I think there’s a vertex limit or something for each mesh. If I reduce the number of meshes I’m combing at a time, it works fine. So I needed to change my setup so each parent gameobject that wants to combine all its meshes only has so many meshes to prevent going over the limit.

One more suggestion for anyone coming here in the future if the other suggestions don’t suit you. You can do this very easily with the “Easy Mesh Combiner MT” plugin available in the Asset Store. Here is the link: Easy Mesh Combiner MT - Scene Mesh Merge, Atlasing Support & More | Game Toolkits | Unity Asset Store