Hi,
I saw lots of forum threads about this issue, but still I didn’t understand something.
We have atlas with 20 sprites, when I load my scene and open the frame debugger, I can see that in one batch there were 9 sprites, then we have some other batches (due to different materials) which is ok, but after it I can see the additional 11 sprites in another batch…
Why do the sprites draw calls not grouped to one batch?
Thanks,
Tomer
Since you’re talking about UI - the order is important. The UI usually has transparency, so it’s not possible to just say “these all have the same material, so we render those together”.
A simple case to better show the problem: imagine a button with text and an image. The button has a background sprite, the text is rendered using a different material, the image is in the same atlas as the background. The order in the scene is “background, text, image”. Now, if we try to batch the background and the image together, the text will appear above the image, which doesn’t follow the order in the scene and is incorrect.
1 Like
Ok, thanks for the answer!
But what if I have multiple buttons instances, with the same structure as you described(Background, Text,Image), all over the scene?
How do I enforce that all the buttons will be grouped to only 3 batches totally? (Instead of 3*Number of buttons).
I’d have them flat in the scene hierarchy - first all backgrounds, then all text, then all images.
It wouldn’t, however, be 3*number of buttons in the regular layout. Background of button N would be batched with the image from the button N-1 
Ok, say I have 1 canvas, what defines the order of drawing under it?
Maybe I’m missing something, but in my project hierarchy I have kind of the following structure:
Main: (Canvas)
Images:
-
Image1
-
Text1
-
Image11
-
Image2
-
Text2
-
Image22
-
Image3
-
Text3
-
Image33
Additionals:
-ImageAdditional
I would expect to batch (Image1, Image2, Image3 - sitting on the same atlas), but instead it takes Image1 + ImageAdditional to be in one batch…
What can cause this kind of ordering? I’m using version 2017.1.1f of Unity, maybe there were bugs related to the drawing order?
BTW, my scene is more complicated than the above example, so I have lots of breaking batches…
Well, I would expect this to batch as
- Image1
- Text1
- Image11 + Image2
- Text2
- Image22 + Image3
- Text3
- Image33 + ImageAdditional
(if ImageAdditional sits in the same atlas, otherwise the last one should become two, but maybe not, depends on other options, I guess).
2 Likes