Version: Unity 6.1 Alpha (6000.1)
Language : English
Introduction to static batching
Batching moving GameObjects

Enable static batching

Unity can perform 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
at build time and at runtime. As a general rule, if the 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
exist in a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
before you build your application, use the Editor to batch your GameObjects at build time. If you create the GameObjects and their meshes at runtime, use the runtime API.

When you use the runtime API, you can change the transform properties of the root of a static batch. This means that you can move, rotate, or scale the entire combination of meshes that make up a static batch. You can’t change the transform properties of the individual meshes.

To use static batching for a set of GameObjects, the GameObjects must be eligible for static batching. In addition to the criteria described in the common usage information, make sure that:

  • The GameObject is active.
  • The GameObject has a 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, and that component is enabled.
  • The Mesh Filter component has a reference to 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.
  • The mesh has not already been combined with another Mesh.
  • The GameObject has a 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, and that component is enabled.
  • The Mesh Renderer component does not use any Material with a shaderA program that runs on the GPU. More info
    See in Glossary
    that has the DisableBatching tag set to true.
  • Meshes you want to batch together use the same vertex attributes. For example Unity can batch meshes that use vertex position, vertex normal, and one UV with one another, but not with meshes that use vertex position, vertex normal, UV0, UV1, and vertex tangent.

Note: To use runtime static batching you must also set the mesh to have read/write enabled.

For information about the performance implications for static batching, refer to Performance implications.

Enable static batching at build time

To improve rendering performance, you can enable static batching at build time in the Editor.

Multiple static GameObjects are then combined into a single batch, reducing the number of draw calls at runtime. This is useful in projects with many static objects, such as large, non-dynamic scenes.

To perform static batching at build time:

  1. Go to Edit > Project Settings > Player.
  2. In Other Settings, enable Static Batching.
  3. In the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
    See in Glossary
    or Hierarchy window, select the GameObject that you want to batch, to view it in the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
    See in Glossary
    window. You can select multiple GameObjects at the same time to enable static batching for all of them.
  4. In the GameObject’s Static Editor Flags, enable Batching Static.

For information about how to set up renderers so Unity can batch them, refer to Using draw call batching.

Note: If you use static batching at build time, Unity doesn’t use any CPU resources at runtime to generate the mesh data for the static batch.

Static batching at runtime

To batch static meshes at runtime, Unity provides the StaticBatchingUtility class. The static StaticBatchingUtility.Combine method combines the GameObjects you pass in and prepares them for static batching. This is especially useful for meshes that you procedurally generate at runtime.

Unlike static batching at build time, batching at runtime doesn’t require you to enable the Static Batching Player Setting. For information on how to use this API, refer to StaticBatchingUtility.

Introduction to static batching
Batching moving GameObjects