Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question on using more than one canvas

Discussion in 'UGUI & TextMesh Pro' started by Shadowing, Feb 10, 2017.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,627
    I'm using a parent canvas and then several child canvas
    The GameObject Canvas is the Parent Canvas

    Map, control UI Chat, Control console is all child canvas

    If something redraws on say Chat does the Parent Canvas redraw as well?
    Is this effecting my performance setting it up this way.
    I have a parent canvas so I can use canvas scale on all.



     
    BruceBai likes this.
  2. Strangiato

    Strangiato

    Joined:
    Oct 24, 2014
    Posts:
    18
    The parent canvas will not need to be recalculated when a child canvas is redrawn.

    This is affecting your performance, but most likely in a good way.

    Whenever a UI element changes a value, the canvas that is resides in will need to regenerate vertex buffer data. This can be an expensive operation if you have a large number of UI elements in your scene (especially on mobile).

    When you use embedded canvases, each canvas will only need to recalculated if an element it owns has changed.

    However, UI elements under different canvases that share texture and shader properties can no longer be grouped into one draw call, so there is a tradeoff. But if you have a large UI, it's worth the effort. Use the profiler and you can judge how your changes are affecting your performance.
     
  3. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    In my experience, multiple canvases are not required for most situations. Better to have a single canvas and simply use multiple panels within that canvas for different screens / menus, then simply activate / deactivate them accordingly.

    Also with the multi-scene management, a fair few titles are now having a UI dedicated scene which is simply added to the mix for your project.

    Check out Unity's UI sample on the Asset store for a great demonstration of this.

    Only reason to have multiple canvases, is if you want different scaling modes / factors, / etc
     
    jorgecastillodp likes this.
  4. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    168
    Old thread, but just wanted to point out that this is actually not true and that it's recommended to have multiple canvases due to the entire canvas being redrawn with one single change. If you had multiple panels this would affect performance heavily.

    Check out this talk
    and as well this site: https://unity.com/how-to/unity-ui-optimization-tips

    I do wonder though as the OP, if I have a canvas component at the parent object like shown in the image in the first post, what will be the impact then? I currently use a normal parent game object but this gives SendMessage warnings now in Unity 2022.