Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Canvas and multiple panels vs multiple canvas in Unity 3D

I'm developing a Holographic app for Hololens using Unity 5, I need to create some UI, so Which approximation would provide a better performance?

A single canvas with multiple panels or multiple canvases?

I need multiple UI elements (Text labels, buttons, etc...) with different locations specially with different Z axis values.

like image 796
Eduardo Corona Avatar asked Oct 08 '18 21:10

Eduardo Corona


People also ask

Should I use multiple canvases unity?

So having one giant Canvas for your whole UI is not recommended by Unity. Just separate out different parts of your UI into different Canvases where they make sense and however they're easier to work with.

Can you have more than one canvas in a scene unity?

A single Canvas for all UI elements is sufficient but multiple Canvases in the scene is possible. It is also possible use nested Canvases, where one Canvas is placed as a child of another for optimization purposes. A nested Canvas uses the same Render Mode as its parent.


1 Answers

Unity guys specifically gave a performance talk about UI Canvases on some of the past Unite(s). You won't have trouble finding it on Unity's YouTube channel (edit: here it is - Unite Europe 2017 - Squeezing Unity: Tips for raising performance). Basically they saw a trend of performance problems in projects with more complex UIs. The problem arises from the fact that when one single UI element is modified it marks its whole canvas hierarchy as dirty. They(Unity) highly encourage to separate different ui parts in their own canvases. Especially elements that are updated per frame (or just too often) should be in their small separate canvases - things like healthbars, scrolling inventories and the like. Of course don't go on the other end with one canvas per element, just be wise with the different UI parts and dynamic UI elements. The ordinary gameObject hierarchies have the same problem but there the performance hit for recalculating the whole hierarchy is much smaller compared to UI.

like image 189
Nikaas Avatar answered Sep 24 '22 02:09

Nikaas