Canvas Disabled but UI elements still block Raycasts

I have this hierarchy of Canvases
Canvas_Parent

  • UI Elements
  • Canvas_Child
    • UI Elements
  • Canvas_Child
    • UI Elements

In order to turn them all off at once I disable the Canvas Component on Canvas_Parent. However, the UI Elements under Canvas_Child continue to block Raycasts while the ones directly under Canvas_Parent do not.

Pretty Frustrating
All of the UI Elements within the hierarchy do not block Raycasts until the Canvas_Parent component is enabled for the first time

How can I ensure no UI ELements in that hierarchy block Raycasts when I disable Canvas_Parent component?

Note: I can’t use SetActive on the gameobject to just close down the full hierarchy for performance reasons.

Try disabling “Graphic Raycaster” component on Canvas.

Hi maybe this can help.
If you want to disable all children along with parent, I did by

parent.setActive(false); 

And later to enable.

parent.setActive(true); 

Then nothing is blocking raycast.
In your case you disabling 1 canvas so other canvases are still active.

Maybe you should consider structure like:

popUpMenu (no canvas - just control script)

  • Menu1 (with canvas)
  • Menu2 (with canvas)
  • Menu3 (with canvas)

in control script you just put:

public GameObject menu1;

public GameObject menu2;

public GameObject menu3;

And then popUpMenu is always active to keep script active and to keep children accesible and depending on action you just do menu1.setActive(true)… menu2.setActive(false)… etc
you can turn on or turn off any of them at any time.

hi, adding a CanvasGroup component to the Canvas_Parent and change property .BlocksRaycasts to false works for me. Remember to change this property to true when you activate the canvas component again.

hope it helps

Antonio

Add a canvas group and disable the checks interactable and blocks raycast.