Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Architecturally, is it normal to have multiple canvas in your scene?

Discussion in 'Unity UI & TextMesh Pro' started by rickblacker, Jul 13, 2018 at 7:30 PM.

  1. rickblacker

    rickblacker

    Joined:
    May 1, 2014
    Posts:
    192
    Without going into a lot of boring detail. Is it acceptable to have multiple Canvas in your scene? The biggest reason I'm wanting multiple is because each thing I want on the canvas does a different thing. Like, displaying images, fading alpha, playing video. Each needs the ability to be displayed and hidden.
     
    Last edited: Jul 13, 2018 at 7:43 PM
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    5,795
    Its fine. Probably not the fastest if you scale it up but it's normal.
     
  3. rickblacker

    rickblacker

    Joined:
    May 1, 2014
    Posts:
    192
    Speed in this particular app is not a concern. Ok, cool. I just wanted to make sure I wasn't attempting to break some kind of "best practice".
     
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,267
    IIRC, any time you make a change to something on a canvas, it redraws the whole canvas. So you do want to separate out functions that update independently.
     
    dadude123 likes this.
  5. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,065
    I have a canvas for each GUI 'screen', so at most there's usually only 2 canvases shown (GUI screens crossfade)
     
  6. eatsleepindie

    eatsleepindie

    Joined:
    Aug 3, 2012
    Posts:
    259
    You want to group items in canvases so that the group is getting updated as a whole whenever possible without updating anything else. For instance, if your resource calculations run once per second in your RTS, you want to update your header's resource counts all at once and also have those separate from a canvas that updates when the player interacts with it. Also make sure you turn off raycasting for any UI elements that don't require it, which can degrade performance, especially on mobile.
     
    TonyLi and hopeful like this.
  7. Fuzzy_Slippers

    Fuzzy_Slippers

    Joined:
    Dec 21, 2012
    Posts:
    461
    Yeah I believe you should actually have a bunch of canvases. My current game has like 6. Unity doesn't make these kinds of best practices very obvious.
     
    hopeful likes this.
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    8,021
    This is a good resource: A guide to optimizing Unity UI

    In particular, this section: Fill-rate, Canvases, and Input.

    This isn't just when you activate or deactivate a GameObject or change the content of a Text element, but also every single frame if it has an active Animator. The guide has tips for avoiding these issues, such as using a tween script instead of Animator, and disabling canvases efficiently.
     
    hopeful likes this.
  9. Fuzzy_Slippers

    Fuzzy_Slippers

    Joined:
    Dec 21, 2012
    Posts:
    461
    It seems like then you do want to split up all your elements from the commonly updated ones. Like canvases split among HUD (health bars and such) Top Elements (cursors, tooltips) Frequently Changed Menus (character screens, inventories) Irregularly Changed Menus (book screen, death screen, map) and Static Menus (main menu, save/load menu)

    That way every time you change cursor you aren't rebuilding a very complicated hierarchy like a main menu. The penalty of a few extra draw calls seems worth it.