Combine static meshes at build time or at runtime. For more information about batching, refer to Introduction to static batching.
You can enable static batching in two ways:
To batch static GameObjects at build time, enable static batching. For more information about batching, refer to Introduction to static batching.
Follow these steps:
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 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.
To batch static GameObjects at runtime, for example GameObjects you create procedurally, follow these steps:
Select each mesh you want to batch, then in the Inspector window enable Read/Write enabled.
Use the StaticBatchingUtility API to batch the meshes. The StaticBatchingUtility.Combine 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 API with markNoLongerReadable set to true.
You don’t need to enable the static batching setting in the URP asset, HDRP asset, or Player Settings.
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.