We are currently trying to improve our UI by using batch groups and we ran into an issue which we are not really sure how to fix.
We are creating quite a few ui elements dynamically. Of those elements, the item we are trying to display can not be batched. They are colored differently from each other (Red and Blue), so each of them internally has their own material, so even though their sprite assets share the same texture atlas, they cannot be batched.
Then we also want to show highlights (Yellow) on top of them. Those are not colored, always the same and the various highlights are in the same atlas, so they can be in the same batchgroup.
What we want to see is the following:
But what we actually see is this:
This is because of the number of drawcalls, which we want to reduce, and our hierarchy.
The first image has 5 draw calls
The second image has 4 draw calls because of the batch group on the highlights
- Batch group with both highlights
We tried fixing this by adding another layer for the highlights and rendering the batchgroup in there. Under other circumstances this would work, but our elements are all inside a scrollView. It seems like inside a scrollview only the ui layer can be rendered? We are very confused about this behaviour.
Could you please give us an idea of how to fix the rendering order? Or can you give us insight on how to render other layers than the ui layer inside a scroll view? Here is a sample project with a setup similar to our project.