Sm2 draw calls with instantiate

hey there,

am working with sprite manager 2 and all is going great. in the process of optimizing draw call still and have a question.

it seems that when i spawn some enemies ( whom all share the same sprite atlas ) it makes a draw call for each instantiated prefab.

also, i have towers that i drop in ( tower defence ) and their instantiating does not add a call for each one.

i cant see what i am doing different. has anyone had the same problem and have a tip?

thanks much,
chris

Sounds like you have more than 1 material on these enemies.

batching does not work on object but material only

dreamora is correct about batching. However, you may be looking at the wrong figure in the Stats. Be sure you are looking at “Emulated Draw Calls” as opposed to “Editor Draw Calls”. The former is what you will actually get on the iPhone.

thanks .
yes it was the material.
i had a health bar that was on the sprite atlas and was changing the alpha and color. each adding its own draw call.

thanks lots,
chris

You can modify the alpha and color by changing the sprite’s “color” property - this uses vertex colors to achieve the effect rather than modifying the entire material color (which kills batching).