Handling many Canvas objects (or: How to ignore raycast on a disabled canvas?)

Maybe I’m doing this completely wrong here, so bear with me.

In my project I have different UI systems (Inventory, Skills, Equip and so on). Of course not of all them will be visible at once, some may be hidden some may not. At first I tought that using one canvas and drawing all inside that would be the best way of doing it, but I need some way of disabling all the children of a given gameobject at will. To do that I then used a Canvas component for each UI system and grouped eveything inside that. Whenever I disable the Canvas component of the parent, all of the gameobjects hides aswell.
So far so good. Now I’ve encountered two problems doing this:

  1. If I group more than 4 canvas in one global canvas, some of them will not be visible. They’re there, but they just don’t show up. This is the first sign that I’m doing something wrong.
  2. While a widget is hidden, it will ocassionally block mouse events on visible canvas if they overlap. I tried disabling the Graphics Raycaster to no avail. This is the second sign I’m doing something wrong.

Now before I go and either remake the whole UI system or write a custom component to handle the “disabling” of the ui system, am I missing something here? Probably.

Thanks for reading :slight_smile:

I ended up writing my own system for handling multiple UI elements and it now works just fine. Plus I was using Canvas completely wrong :slight_smile: my bad

1 Like

You could try Canvas Group. You can hide groups and stop them catching raycasts.

1 Like