Need help with optimizing draw call reduction

Hi, I’ve noticed that my game is experiencing lag spike when objects are instantiated. (More draw calls).

I’m trying to combine the textures i’m using for my GUIs into a single texture.
I’ve read around the forums about using a single texture to reduce draw calls but I do not understand how to clip the atlas so that each object is showing a different image.

Another problem i had is, for each object i instantiated, the particle emitter that each object contains is adding 1 more draw call to my game. Is there anyway to combine them so that it is counted as a single draw call?

Edit: Btw i’m working on a 2D game.

Thanks.

As for GUIs: I would recommend to look into SpriteUI / GUITexture and using them.

You can’t get multiple particle emitters onto a single surface as they are optimized to run as optimal as possible “within themself”.

As for the lag spikes: I would check if the lag is caused by the instantiation or by the work the GC has to do to get rid of the flood of objects again.

Thanks for the suggestion, I’ll try using the SpriteUI.

I am thinking of switching particles to sprite animation since they will be under the same texture and hence reducing the draw call.

Precalculated particle effects especially for explosion and electricity based things is a great way to save a lot of performance if you use UV animations to do them.

The way I use sprites in my latest game is by creating two-poly meshes by code. I have a sprite component that I add to gameobjects, and in the properties panel I can setup the UV coordinates. Since I kept my sprite class to a bare minimum (it basically just adds a renderer and a mesh), this approach should be a bit faster (with Unity 1.5) than using some of the pre-batching solutions, because those were adding all the sprites to one mesh. However, I didn’t do any benchmarking.