lowering draw calls

I have a situation where i have an cubePrefab object that i instantiate to create a grid of 120 cubes at the start of a level. They all have the same material, but use a texture atlas to display one of 8 different colors. Currently, I have about 140 draw calls happening in my game. Given this situation is there any room for lowering my draw calls, or should I look else where?

The only other objects i have are a cube with has a black material on it, three other cubes, each with there own material, and two GUI_Text objects, that are using standard unity fonts to display (nothing imported or used as a new font)

I've read other posts, but it seems that most answers lead to combining meshes, but this cubePrefab needs to move around, be destroyed, recreated, yadda yadda... is this still the way to go?

any tips? thanks unity answers!

Not sure how you are doing the texture atlas, but something is preventing Unity from combining the cubes into one draw call.

If you instead had a simpler setup: 8 different cube prefabs, each with its own material with a single texture, I believe you'd end up with only 8 draw calls for all the cubes.

Try a test case making copies from a single cube prefab. Once you can do that in a single draw call, you can either clone that 8 times, or use what you've learned to try to figure out what it is about your original solution that's confusing the engine.

See also this answer: http://answers.unity3d.com/questions/15567/dynamic-batching

Edit: Here is a useful forum discussion about other things that can interfere with batching. Multipass shaders apparently won't, for example. In addition, when running in the editor in Deferred lighting mode, apparently some shaders run multipass even though they wouldn't on an actual iOS device. (Setting Edit->Graphics Emulation correctly might be enough to fix that.)

The draw calls you are seeing is normal for what you are doing.

You need to write a custom Combining script.

Create an empty GO parent object Make all the cubes children of that parent.

The children have their renderer turned off. Any colliders will still work, because the GO is still active. They get combined into the parent.

When a change happens to a cube, you combine the child meshes into the parent again.

I do this with 1024 "cubes" in less than 30ms, last time I checked. i7-920, Radeon 5870

I dont do animation with them, just manual editing. If you where sliding boxes around all the time, that might be a problem.

I use Mesh.CombineMeshes()

Just for the Record: The Problem is that you create your Cube bei Instancing an prefab. This will lead to an instance of your Material. (If you pause the game and select the Cube - you should see Matial:Name (Instance) in the bottom of the Inspector. If there is just Material:Name shown - I´m wrong.)

To get rid of this Problem you can change the Material in the start of your script like:

void Start(){
renderer.sharedMaterial = YourUniqueMaterial
}

Good Luck

Just for the Record: The Problem is that you create your Cube bei Instancing an prefab. This will lead to an instance of your Material. (If you pause the game and select the Cube - you should see Matial:Name (Instance) in the bottom of the Inspector. If there is just Material:Name shown - I´m wrong.)

To get rid of this Problem you can change the Material in the start of your script like:

void Start(){
renderer.sharedMaterial = YourUniqueMaterial
}

If you have a complex scene containing high polygon 3d models with a lot meshes that use a lot of different materials, the overall performance of your game will suffer. You can check out my tool on the unity asset store “Poly Few” that aims to solve this problem by allowing you to optimize high quality complex 3d scenes. With integrated features like mesh simplification, automatic LOD generation, mesh merging and material combining, you can greatly improve the performance of your game by lowering the Polygon Count, DrawCalls and SetPass calls with a few clicks and, without the need of writing even a single line of code.