Sub-canvas and Graphic Raycaster

Hi all,

Looking at the doc I am unsure how nested canvases (aka sub-canvas) receive input.

- Do I need Graphic Raycaster on root canvas?
- What kind of performance issue I may face having Graphic Raycaster on each sub-canvases?

From my own test, it’s apparent sub-canvas somehow isolate its children from parent canvas, not just in a layout/graphic rebuilt sense, but also in a raycast sense: root canvas Graphic Raycaster doesn’t register input on Sub-canvas elements.

The reason I am running into this problem:

  • I design my UI to be modular and each module listen for events that will ask the module to enable/disable/update itself.

  • I don’t want to disable the gameObject as it will also disable the listener.

  • So I have two choices:

(A) Use wrapper object and put my script on it, which will disable the actual UI gameObject below the wrapper

(B) Use sub-canvas and just disable the canvas component.

I went with (B) and it now seem I should have picked (A).
Any suggestions?

3 Likes

I use the B plan and for each sub canvas, they need to have their own graphic raycaster.
But another issue arise. When the parent canvas is disabled, the whole canvas including the subcanvas do not render, but the child canvas still receive input.