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:
DisableBatching
tag set to true.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.
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:
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.
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.