How to combine meshes?

For performance issues, how do you programmatically combine two (or more) meshes into one? Can you point to or give a short pseudo code example?

Thank you.

One of the scripts in Standard Assets (CombineMesh) does just this. I believe it can only do it at startup, but if you’ve got a need to do it some other time, it’s probably the best place to look for an example.

Thanks!

I found MeshCombineUtility.cs in the Standard Assets folder. It does what I need.

I have the combinemesh script working, but I don’t know if I’m getting real benefits. Here is the scenario: I have 200 gameobjects being instantiated all children of a single gameoject which contains the combinemesh script. When I run it, the meshes of the 200 objects are disabled and a single new mesh is created in the parent object.
But I am not noticing much (if any) difference in my fps count. Is there something else I should be doing? Is there a problem because each of my 200 objects have their own texture?

Thanks,
Randy

Yep. The only real savings you get is if the objects that are combined share the same material. You really have 200 different textures? That seems kind of high. If so, maybe look into using texture atlases instead, which would reduce the number of textures and allow you to do effective combining. On the other hand, that’s not usually feasible for textures that need to tile.

–Eric

Yeah its designed for big terrains of multiple meshes, tileable textures, minimum materials as poss…
AC