# Enable static batching

> Enable static batching to combine static meshes at build time or at runtime.

Combine static meshes at build time or at runtime. For more information about batching, refer to [Introduction to static batching](/engine/6000.7/manual/analysis/graphics-performance-profiling/reduce-draw-calls/draw-call-batching/draw-call-batching.md).

You can enable static batching in two ways:

* [At build time](#batch-static-meshes-at-build-time)
* [At runtime](#batch-static-gameobjects-at-runtime)

## Batch static meshes at build time

To batch static GameObjects at build time, enable static batching. For more information about batching, refer to [Introduction to static batching](/engine/6000.7/manual/analysis/graphics-performance-profiling/reduce-draw-calls/draw-call-batching/draw-call-batching.md).

Follow these steps:

1. Go to **Edit** > Editor > **Player**.
2. In **Other Settings**, enable Editor.
3. In the Scene view or **Hierarchy** window, select the GameObject that you want to batch. You can select multiple GameObjects at the same time to enable static batching for all of them.
4. In the Editor window, select the [Static Editor Flags](/engine/6000.7/manual/working-with-gameobjects/gameobject-fundamentals/static-objects.md) dropdown and enable **Batching Static**.

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.

> **Note:**
>
> Unity uses additional memory to store the combined meshes, even if the meshes are the same. For example, marking trees as static in a dense forest environment can have a large impact on memory. If static batching uses too much memory, [combine meshes manually](/engine/6000.7/manual/analysis/graphics-performance-profiling/reduce-draw-calls/draw-call-batching/combining-meshes.md) instead.

If a mesh is culled because it's outside the camera view, Unity might not be able to draw all the meshes in a single draw call. This is because the culled mesh leaves a gap in the combined vertex buffers.

## Batch static GameObjects at runtime

To batch static GameObjects at runtime, for example GameObjects you create procedurally, follow these steps:

1. Select each mesh you want to batch, then in the **Inspector** window enable **Read/Write enabled**.

2. Use the [StaticBatchingUtility](/engine/6000.7/script-reference/unityengine/staticbatchingutility.md) API to batch the meshes. The [StaticBatchingUtility.Combine](/engine/6000.7/script-reference/unityengine/staticbatchingutility/combine.md) method combines GameObjects and prepares them for static batching.

> **Note:**
>
> To avoid the read/write mesh using double the amount of memory, you can now delete one copy of the mesh by calling the [`Mesh.UploadMeshData`](/engine/6000.7/script-reference/unityengine/mesh/uploadmeshdata.md) API with `markNoLongerReadable` set to `true`.

You don't need to enable the static batching setting in the URP asset, HDRP asset, or Editor.

If a mesh is culled because it's outside the camera view, Unity might split the batch into two batches, to avoid a gap in the combined vertex buffers.

You can only change the position, rotation, and scale of the whole batch at runtime, not the individual meshes.

## Additional resources

* [Choose a draw call optimization method](/engine/6000.7/manual/analysis/graphics-performance-profiling/reduce-draw-calls/optimizing-draw-calls-choose-method.md)
