[ad_1]
We all know that each UI factor must be a toddler of the Canvas. The Canvas has a main activity of managing the meshes which might be used to attract the kid UI components of the Canvas and subject draw calls which might be essential to render all UI components which might be kids of that Canvas.
Now, one necessary factor to grasp is, every time any change is made to the Canvas or any of its kids, this is called dirtying the Canvas, and every time a Canvas will get soiled, it must regenerate meshes for all baby UI components earlier than it may possibly subject a draw name.
Now you may solely think about how unoptimized is to place all of your recreation UI in a single single Canvas. Particularly in gameplay scenes the place you have got timers that replace each second which is able to pressure the Canvas to rebuild(regenerate) all of its components earlier than it may possibly subject a draw.
An answer for that is to have multiple Canvas. What I love to do is put UI textual content that show timers in a single Canvas, that approach when the textual content adjustments which occurs typically with timers, the Canvas will solely should rebuild a couple of UI components as a result of every Canvas is unbiased and solely rebuilds the UI components which might be its kids.
However remember, don’t create too many Canvases as that may additionally result in efficiency points. Looking on-line I discovered some individuals saying that you shouldn’t have greater than 4 Canvases on cellular gadgets, nonetheless from testing my very own video games the place I’ve greater than 4 Canvases I came upon that my recreation was working above 60 FPS even on low finish gadgets, so at all times seek the advice of the Profiler earlier than you decide.
A good suggestion is to separate static and dynamic UI components. Static UI components are people who don’t transfer, like labels, logos and background photos. Dynamic UI components are buttons, texts with timers and so forth.
On the subject of dynamic UI components I might additionally separate the weather that change typically from those that don’t, for instance buttons solely change while you hover over them or press them, whereas a timer textual content adjustments on a regular basis.
[ad_2]