- Home /
Good idea to use nested canvases for children of scrollable lists?
I created a scrollable list with 100 items ( https://i.imgur.com/CuLadCe.png ) and tested if it helps performance to give all list items their own nested canvas but it does not really make any difference:
Without the nested canvases: https://i.imgur.com/4eP0TLN.png
With nested canveses: https://i.imgur.com/M5XhMV4.png
So no real difference, even while scrolling. Does the ScrollRect handle this optimization automatically? Maybe I should test which constantly changing children?
Answer by Johannski · Mar 17, 2017 at 07:48 PM
According to this talk from December 2016 it would make sense to add the canvas component to the scroll rect, if I'm not mistaken. Interesting that he didn't mention canvases being added automatically to the ui.
Unite 2016 - Let's Talk (Content) Optimization
You should also think about pooling the items if you're not already doing that. Also take a look at https://unity3d.com/learn/tutorials/topics/best-practices/optimizing-ui-controls
Answer by SioHio · Dec 11, 2016 at 11:57 AM
Ok I just found some information on a blogpost about Unity 5.2 and Optimized Batching :
In Unity 5.2, the batching code was substantially rewritten, and is considerably more performant compared to Unity 4.6, 5.0 and 5.1. Further, on devices with more than 1 core, the Unity UI system will move most of the processing to worker threads. In general, Unity 5.2 reduces the need for aggressively splitting a UI into dozens of Sub-canvases. Many UIs on mobile devices can now be made performant with as few as two or three Canvases.
This might explain why there is no difference on my machine, so maybe using nesting canvases might not be a good idea anymore because it might break more that it adds value/performance?