Quantcast
Channel: Answers for "Combine objects instantiated at runtime"
Viewing all articles
Browse latest Browse all 4

Answer by Tetrad

$
0
0

If you're using Unity 2.6+ there's a built-in function on Mesh called CombineMeshes that's probably preferable over the standard assets CombineChildren script. See the documentation here: http://unity3d.com/support/documentation/ScriptReference/Mesh.CombineMeshes.html

Some caveats of doing what you're suggesting though:

  • If your "Ground" object has collision, triggers, or really anything other than a mesh/mesh renderer on it, you'll probably need to keep the original game object you instantiated around with the mesh renderer disabled/destroyed.
  • [I may be wrong on this, but] Unity doesn't know when exactly it's safe to delete a mesh. Make sure you're not leaking meshes after creating them with CombineMeshes.
  • A single mesh in unity cannot have more than 65000 verts. If you're trying to combine an entire level made up of relatively small, detailed tiles, this might be an issue. You'll have to check manually to make sure your vert count is below that, and if it isn't generate multiple meshes.
  • If you can, make as many of your tiles use the same material as possible (i.e. atlas everything you can), so make it so that you have as few meshes as possible. CombineMeshes will make each mesh it's own submesh, but I don't know how efficient that is at combining draws of submeshes with the same material.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images