Working with multiple canvas??

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

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.

You only need multiple Canvases if you need different scaling for the UI canvas.

1 Like

ok thanks. So far I was creating one canva for each panel I wanted to display. Is there a downside to this?
Many thanks

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

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.

thank you all for your help

This is an old topic, but here you have my solution:

  • In the editor, set canvas render mode to World Space to all your canvas
  • Move every canvas to a different position to allow you an easy edition
  • 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.

1 Like