Batch Objects with Different Colors and Scales

I am fairly new to Unity so this may be my own simple failure but I am currently converting an XNA game to Unity. I have about 8000 objects that need to use the same texture but have random colors and scale that constantly change.

I have noticed that nothing is getting batched and have determined it is because of the different colors/scales.

How can I have objects with different colors and scales still be batched together?

Renderer.SetPropertyBlock.

Unity’s terrain engine uses MaterialPropertyBlock to draw trees; all of them use the same material, but each tree has different color, scale & wind factor.
The block passed to Graphics.DrawMesh or Renderer.SetPropertyBlock is copied, so the most efficient way of using it is to create one block and reuse it for all DrawMesh calls. Use Clear to clear block’s values, and AddFloat, AddVector, AddColor, AddMatrix to add values.

The failure of batching is most likely the material color. If you have ever modified any properties of a material, like color, uv, it will create an instance of the material. You can verify this by checking the [Material] field of the GameObject in the Hierarchy view at run time, and you should see “(Instance)” at the end of each material name.

The “bucket” technique may be helpful. You need to limit the random set (namely infinite) to some finite set. For instance, pre-create 100 random colors and choose from them to simulate random effect. Then, pre-create 100 materials for these colors and every object will be linked to one of them. So, objects that “falls” to the same bucket (color) will share the same material and will be batched accordingly.