Dynamic batching

I'm trying to incorporate dynamic batching into my application. As I understand it, Unity should be automatically batching objects with the same materials. I have a prefab in my Resources folder that is cloned multiple times in the scene and its own texture added to it (one of three). The mesh is a low-poly object, so I know I'm under the limit for batching objects. If I pause the game and look in the editor, the material of the all of the cloned objects become "rocket-01-default (Instance) (Material)". My question is what do I need to do to get these objects to batch? Do they not batch because the material has (Instance) in it after it clones? If so, how do I change this?


Adding a texture to each object makes it have its own unique material, so it can't batch.

How to Make Objects Dynamically Batch in Unity

they must share the same material

the material must not be instanced (check material name in debug inspector)

batching is applied only to meshes containing less than approx 900 vertex attributes in total (check mesh properties for some idea about this; for starters turn off normals & tangents to reduce it)

the textures must not include alpha

scale breaks batching

lightmaps break batching

multipass shaders break batching

layering other objects in between objects trying to batch can break batching

if you are instantiating the object in code, you may be instancing the material; try re-applying the material asset through .sharedMaterial

even within single-pass shaders, some can batch higher vertex attribute counts than others… in particular if you use a shader that colors vertices you’ll be adding attributes

Even so, <300 vertices and one single material for all, they won’t batch if scaled in the editor,
Also it seems that Cloned objects with correct settings won’t batch either.
When you Instantiate a clone, it will be carried out as myobject(clone) and its material as thematerial(clone) this will result in not banching the object, and this is though to spot, as these objects are generated at runtime, so…

Try to put your batching materials into the resource folder, so that you can apply later the correct material, this should do the trick

There appears to be a huge list of ‘what breaks batching’. Is there any way to definitely examine an object, and unity say “This object cannot be batched due to alpha textures” (or whatever) ?

It seems far too easy for your artist to accidentally break batching by making an object 301 polys, or including 1 pixel of alpha, and no-one will have the slightest clue why the framerate suddenly plummeted!

Other things that break batching:

  • Turning on Mesh Compression! No idea why.
  • Using a shader that alters a vertex position / colour / UV, as this automatically creates an instance of the material.

public Material defaultMat;
public GameObject instantiateThis;

void Start () {
defaultMat = transform.renderer.sharedMaterial;

public void InstantiateObject(){
GameObject newObj = (GameObject)Instantiate.(instantiateThis, transform.position, Quaternion.identity);
newObj .transform.renderer.sharedMaterial = defaultMat;

This solved my problem with instantiating objects and assigning a material while taking advantage of batching, may help others