how can i disable everything behind ui panel?

i have a scene where my game is active, i also have a button which toggles a menu (ui panel) on top of the game… but clicking on the panel also interacts with the game underneath the panel…

how can i make it so that everything under the panel is not intractable??

thanks!

Hi,
You can use Canvas Group’s Blocks Raycasts property. Add it to your panel so only his children will be interactive.

2 Likes

I meant the objects out side of the panel…

I did a work around, which solves my issue.
i check to see if timescale is 0, if it does, ignore all click events.

Glad, that you solved.
Just to be more precise on my answer, you should add Canvas Group to panel or panel’s background that fills screen, so it will block everything behind it.

I tried your suggestion; however it does not work, I tested with Unity 4.6.1. Even though having a full screen panel as last sibling in the Canvas hierarchy, I can still control the other game elements that appear before the Panel. As per your suggestion, I added Canvas Group with Blocks Raycasts to the panel.

Umai, sorry I misunderstood this question. I was talking about block interactions with others UI elements, but seems that this is not the case.
I think you should go with mrm83 workaround, sorry!

How are you doing the raycast? If you are manually doing the ray cast then you can check EventSystem.IsPointerOverGameObject.

The solution mentioned above will only work if you are using a physics raycaster to interact with your game. In general I would suggest using the event system to raycast. Let Unity do all the hard work.

1 Like

And here is the YouTube tutorial, if you are interested.

6 Likes