Sprite batching

Is it possible to get sprite batching to work regardless of what order your sprites are drawn in? From testing it seems that every time a different sprite is going to be drawn, it ends the current batch. So if I have 3 sprites, 10 each, and I set the “order in layer” at random, I get lots of draw calls and not much batching. If I set them so that all 10 sprites of each type are drawn together, I get 3 draw calls, perfect batching.

I understand batching might not be possible/practical if the sprites actually overlap, but in my case I have some that overlap and some that don’t. While I could write my own logic to order things in an optimized way, I’m hoping that something already exists in Unity.

Yes, make sure that the sprites are in the same atlas. When you select a sprite, (Texture type should be sprite), look at the inspector and choose sprite mode ‘Multiple’. Then, make sure you give the sprite a packing tag. Sprites with the same tag will be packed and batched together as soon as you run it in the Editor.

Note: You also have to set Edit > Project Settings > Editor > Sprite Packer Mode to ‘Always Enabled’