Search Unity

Any good reasons for using multiple Canvas objects?

Discussion in 'UGUI & TextMesh Pro' started by casimps1, Jan 1, 2015.

  1. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    I know using multiple Canvases is supported in Unity, but is there any good reason to do this?

    From my understanding, adding extra Canvases will just increase draw calls when you could just as easily handle management of UI elements via the children of a single Canvas.

    Originally, I thought I needed two Canvases if my UI was partially 2D (Overlay) and partially 3D w/ perspective distortion (Camera), but now I'm not even sure of that. I reworked my UI to use a single Screen Space - Camera Canvas and I just leave all my 2D elements at the specified camera plane. Seems to work like a charm and I don't have to worry about managing draw order or raycast blocking across multiple Canvases.

    Now I'm guessing that at most a single Screen Space and single World Space Canvas would be all that's really necessary for any UI. Thoughts? Counter-examples?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Performance, so updating one element doesn't update everything.

    --Eric
     
    navinverma and DanSuperGP like this.
  3. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    Ah, interesting. So, if I have one group of elements that are constantly animating or otherwise changing, and another group that is pretty much static, then it would be beneficial to separate them into two Canvases?
     
    DanSuperGP likes this.
  4. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    @Eric5h5 Could you elaborate on what causes an element update to update the whole canvas?

    With the Unity profiler, I have noticed that simply changing the value of a Text component in a complex UI causes a lot of overhead with nested layouts in our game. I don't know if that is related to there being a lot of elements in the Canvas or if it's simply because of the hierarchical layouts. Would creating a new Canvas just for the frequently changing Text be better? (generally speaking... Of course, specific cases may vary) This is similar to the question posted by @casimps1.

    Would changing RectTransform sizes, scales or positions cause an update to whole Canvas, then? Or is this wrong? What about simple sprite changes? Do they cause updates? (nothing changes in sizes or positions; just a different rendered image)

    Furthermore, is there some link where this is explained in detail?

    Thanks to anyone for any insights. :)