At some points in my game, a menu is meant to pop up, all action stops, and the player is not meant to be able to interact with any of the objects in the game except the menu to choose a button, or click anywhere else to close the menu without selecting anything. In order to allow “off menu” clicks I had the idea of using a second canvas to hold these popup pause menus, and have the canvas itself catch all clicks that miss the buttons, stopping any click reaching the objects behind. So I have this second canvas, I have given it sort order 1 (the permanent canvas is sort order 0) and I have added a Canvas group component with Alpha = 1, Interactable = Check, Blocks Raycasts = Check, Ignore Parent Groups = Unchecked. I don’t have any parent groups I don’t think.
Am I misunderstanding what can be done with a canvas? I have seen various suggestions involving special events but I am thinking wtf, isn’t it simpler just to block the clicks with a non-pass canvas that can be active or inactive according to whether the game is on a pause menu or not.
you actually don’t need a canvas to block clicks. an object with an image and “Raycast Target” enabled is enough (not sure how multiple canvases behave).
Keep in mind that this will only block clicks to UI elements. If you are using 3D or non-UI-2D objects which can be clicked you will still receive those clicks.
Well I tried using the canvas because it was the one thing I knew would automatically cover everything on the screen. It’s the actual game objects on the screen I wanted to block from interacting with the user while the menu was up, so I kind of wanted to “shield” them them under the canvas. I don’t want to write in code to every object testing if the menu is showing or not before accepting clicks! Fortunately I am using a ClickManager system rather than OnClick on each object. So I can test in the Update() of the ClickManager and simply not act on clicks to the objects during that time.
I dont think use only canvas can block the click, you should add image or button with color alpha set to zero ( and off course raycast target enabled) to block the click.