Best practices and optimization techniques for UIs
In this section, we are going to talk about some optimization techniques for UIs along with some best practices to have a better performance. Let’s get started.
Splitting up Canvases
Issue: Modifying a single element on the UI Canvas triggers a complete Canvas refresh, impacting performance.
The Unity UI relies on the Canvas as its fundamental component. It creates meshes representing UI elements, refreshes these meshes when there are changes, and sends draw calls to the GPU for actual UI display.
Mesh generation is resource-intensive, requiring UI Elements to be grouped into batches for efficiency in draw calls. Due to the cost of batch regeneration, it’s essential to minimize unnecessary refreshes. The challenge arises when even a single element changes on a Canvas, prompting a full Canvas re-evaluation to determine the optimal way to redraw its elements.
Many users construct their entire game’...