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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Working with multiple canvas??

Discussion in 'UGUI & TextMesh Pro' started by Tharmine02, Nov 3, 2016.

  1. Tharmine02

    Tharmine02

    Joined:
    May 5, 2014
    Posts:
    25
    Hi all,

    I hope my question will sound trivial because it is driving me crazy.
    When you have multiple canvas in your scene, how to you hide/display the one that are in the way to focus only on the one you are working on? Without enabling/disabling all the others? Can you not just "focus/isolate" on one?

    thank you in advance,

    regards

    Thomas
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    If you need multiple panels for different menu's, then you don't need multiple Canvases.
    Check the UI sample on the asset store, which has a multi-panel UI menu system layout to see how best to do this.
    https://www.assetstore.unity3d.com/en/#!/content/25468


    You only need multiple Canvases if you need different scaling for the UI canvas.
     
    Tharmine02 likes this.
  3. Tharmine02

    Tharmine02

    Joined:
    May 5, 2014
    Posts:
    25
    ok thanks. So far I was creating one canva for each panel I wanted to display. Is there a downside to this?
    Many thanks
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    No real downside that I'm aware of, but a Canvas is a fairly heavy component with a renderer dependancy. Just using empty objects with RectTransforms on the canvas just makes sense to only use what you need without that overhead.

    Like I said, the only reason I've ever used more that one canvas was to change from SS to WS or to SS-Camera. Or to have a different Canvas Scaler
     
  5. Adamcbrz

    Adamcbrz

    Joined:
    Jul 13, 2011
    Posts:
    21
    From what I understand canvas have to redraw everything under them when any item needs to be redraw. That means if you have a value that changes frequently but most of your other items don't change it might make sense to put that item on a separate canvas so they don't have redraw everything when the high frequency item changes. I worked on a team where we had a sims like ui system. That system had to be broken apart because it cause some performance problems when having everything on the same canvas.

    Exception to this rule. If you are doing a menu system that every change to the menu is pretty much a full screen/panel change then doing that all on one canvas will work.
     
  6. Tharmine02

    Tharmine02

    Joined:
    May 5, 2014
    Posts:
    25
    thank you all for your help
     
  7. pacolaf

    pacolaf

    Joined:
    Feb 2, 2014
    Posts:
    5
    This is an old topic, but here you have my solution:

    1. In the editor, set canvas render mode to World Space to all your canvas
    2. Move every canvas to a different position to allow you an easy edition
    3. In your script Start() function, change the render mode to Screen Space - Overlay (or Screen Space - Camera) for every canvas:

    GameObject myCanvas = GameObject.Find("My Canvas");
    myCanvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;


    Of course, you have to show or hide every canvas according to your needs. For example, also in Start() function:


    myCanvas1.SetActive(true);
    myCanvas2.SetActive(false);
    myCanvas3.SetActive(false);


    I hope this helps.
     
    drift_pattern likes this.