Runtime Mesh Batcher

Runtime Mesh Batcher

2014, scripting asset.

Runtime Mesh Batcher is a script extension for Unity which provides an affordable, easy and fastway to combine multiple individual meshes at runtime, reducing draw calls and improving performance.

While other solutions available on the Asset Store offer greater in-editor capabilities and much more options, this script is specifically designed to provide a plug-and-play solution for games which create their environments procedurally at runtime.

 

  • Clean and professional code.
  • Works with Unity or Unity Pro.
  • Custom inspector.
  • Automatic Batching mode through custom Tag or Layer.
  • Manual Batching mode for advanced scenarios (by providing a GameObject array).
  • Can be used with a controller GameObject for setting options in the Editor or directly from script.
  • Fast and optimized operation: combines 100K individual meshes in under a second.
  • Combines complex object hierarchies with multiple materials.
  • Automatically handles Unity’s 64K vertex limit – you can combine an unlimited number of meshes without worries.
  • Batching process is reversible (v1.1).
  • Batching can be done following a grid for culling purposes (v 1.2).
  • Clear documentation.
  • Demo scene provided.

Demonstration Video

 

 

Documentation

 

Manual

You can download the pdf documentation here: Runtime Mesh Batcher Manual v1.2.1

Changelog

Version 1.2.1:

NEW FEATURES:

  • Added an option to the RuntimeMeshBatcher inspector Controller to automatically batch objects at startup, if the batching is to be done only on meshes created in the editor, not at runtime.

IMRPOVEMENTS:

  • Updated documentation.

FIXES:

  • Fixed a crash which could happen if a gameObject sent to RuntimeMeshBatcher had no MeshRenderer components on it or its children.
  • RuntimeMeshBatcherParent objects weren’t properly named in an incremental way

Version 1.2:

NEW FEATURES:

  • Added new option to batch objects in separate meshes following a grid, allowing frusturm or distance culling.

IMPROVEMENTS:

  • Added platform dependent compilation code to use “transform.parent =” for Unity 4.5 and “transform.SetParent()” for Unity 4.6. This keeps compatibility with Unity 4.5 and before while avoiding unnecessary warnings on 4.6.
  • Updated documentation.

Version 1.1

IMPROVEMENTS:

  • Created combined meshes are now parented under distinct GameObjects incrementally named “RuntimeMeshBatcherParent_n”, allowing to easily find them in the hierarchy if needed.
  • RuntimeMeshBatcher.CombineMeshes now returns the newly created parent GameObject. You can keep that reference around to do things with the combined meshes, for example delete or deactivate them, or uncombine them.
  • Added “Destoy original objects” option, if you do not need to keep the original GameObjects for purposes like keeping the colliders on them (false by default).
  • Added “Keep original object references” option, which enables a new UncombineMeshes method to reverse the process (false by default to save memory if you do not need the functionality).
  • Added RuntimeMeshBatcher.UncombineMeshes(rmbParent) which you can call with the reference to the parent object, to undo the batching process.
  • Original GameObjects transform hierarchy is now preserved after the batching.
  • Added tooltips to the custom inspector.
  • Some performance optimizations to the code.
  • Updated documentation.
  • Updated demo scene with new UncombineMeshes option.

FIXES:

  • Small error in the demo scene prefab could cause an undefined Tag error.
  • Removed usage of transform.SetParent to make the script backwards compatible with pre-4.6 versions.

Version 1.0

Initial Release

Comments