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. For information about how to set up renderers so Unity can batch them, refer to Using draw call batching.
To use static batching for a GameObject, the following conditions must all be true:
DisableBatching
tag set to true
.Mesh-isReadable
API for more information.For information about the performance implications for static batching, refer to Performance implications.
Static batching is more efficient than dynamic batchingAn automatic Unity process which attempts to render multiple meshes as if they were a single mesh for optimized graphics performance. The technique transforms all of the GameObject vertices on the CPU and groups many similar vertices together. More info
See in Glossary because static batching doesn’t transform vertices on the CPU. For more information about the performance implications for static batching, refer to Performance implications.
This section includes information about the render pipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary compatibility of static batching.
Feature | Universal Render Pipeline (URP) | High Definition Render Pipeline (HDRP) | Custom Scriptable Render Pipeline (SRP) | Built-in Render Pipeline |
---|---|---|---|---|
Static Batching | Yes | Yes | Yes | Yes |
Using static batching requires additional CPU memory to store the combined geometry. If multiple GameObjects use the same mesh, Unity creates a copy of the mesh for each GameObject, and inserts each copy into the combined mesh. This means that the same geometry appears in the combined mesh multiple times.
Unity does this regardless of whether you use the Editor (refer to Enable static batching at build time) or runtime API (refer to Enable static batching at runtime) to prepare the GameObjects for static batching.
If you want to prioritize a smaller memory footprint, you might need to reduce rendering performance and avoid static batching for some GameObjects. For example, marking trees as static in a dense forest environment can have a serious memory impact.
Note: Each static batch can include up to 64,000 vertices. If there are more, Unity creates another batch.