Simple and CORRECT way to combine 2 meshes?

I have been trying, for about 3 days now, to combine meshes. No script work as all combining tw omeshes together, with their material(s). Even the default CombineMeshes script works, it returns “instans is 0 null” or something liek that.

I jsut want to combine 2 cubes as a test

Here’s the function I use to combine multiple floor meshes into one that in turn gets used as a navmesh during runtime (Astar Pathfinding Project ftw). Now sure about Materials since it doesn’t need any.

List<GameObject> meshObjectList;

public void CombineMeshes() {

     // combine meshes
     CombineInstance[] combine = new CombineInstance[meshObjectList.Count];
     int i = 0;
     while (i < meshObjectList.Count) {
          MeshFilter meshFilter = meshObjectList*.gameObject.GetComponent<MeshFilter>();*

_ combine*.mesh = meshFilter.sharedMesh;_
_ combine.transform = meshFilter.transform.localToWorldMatrix;
i++;
}*_

Mesh combinedMesh= new Mesh();
combinedMesh.CombineMeshes(combine);
}

I think this might be useful to someone in the future… It’s possible to combine meshes from your scenes in a very easy way using the “Easy Mesh Combiner MT” plugin, available in the Asset Store. It is capable of combining meshes and generating atlases (if you need), without loss of quality. You can even do runtime merges. Unfortunately, it’s not free… But it’s pretty cheap. It’s worth checking out. Here is the link: Easy Mesh Combiner MT - Scene Mesh Merge, Atlasing Support & More | Game Toolkits | Unity Asset Store