Introduction to batching meshes
Batch static meshes at build time
Set up GameObjects for batching
For more information about batching, refer to Introduction to batching meshes.
Get the best results from batching
To get the best results from batching, do the following:
- Share materials among as many GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary as possible.
- If you have two material assets that are identical apart from their textures, combine the textures into a single, larger texture.
-
Profile the performance of your application with batching turned on and off.
Check whether Unity batches GameObjects
To check whether Unity batches GameObjects, open the Frame Debugger and check for either of the following:
- Render passes called Draw Static or Draw Dynamic.
-
Combined Mesh in the event details of the Meshes section.
If Unity isn’t batching GameObjects, check the following for each GameObject:
- The GameObject is active.
- The GameObject has an enabled Mesh RendererA mesh component that takes the geometry from the Mesh Filter and renders it at the position defined by the object’s Transform component. More info
See in Glossary component.
- None of the materials in the Mesh Renderer component use shadersA program that runs on the GPU. More info
See in Glossary that have DisableBatching
set to true
.
- The GameObject has an enabled Mesh FilterA mesh component that takes a mesh from your assets and passes it to the Mesh Renderer for rendering on the screen. More info
See in Glossary component with a MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary.
- The mesh has a vertex count greater than 0, and hasn’t already been combined with another mesh.
- The meshes use the same vertex attribute layout. For example, Unity can’t batch a mesh that uses UVs with one that doesn’t.
If you use static batchingA technique Unity uses to draw GameObjects on the screen that combines static (non-moving) GameObjects into big Meshes, and renders them in a faster way. More info
See in Glossary, check the following:
- The GameObject uses the same mesh, shader variant, texture samplers, lightmapA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary, and layer as other meshes you want to batch.
- The mesh is not very small.
- The mesh doesn’t use LODThe Level Of Detail (LOD) technique is an optimization that reduces the number of triangles that Unity has to render for a GameObject when its distance from the Camera increases. More info
See in Glossary fading.
Additional resources
Introduction to batching meshes
Batch static meshes at build time