How to make sure mouse events go to the UI layer

This is a 2D puzzle game in 2 main layers. The game is in the ‘default’ layer at Z=0, camera Z=-10. The UI is in the ‘UI’ layer and the top canvas is in render mode Screen Space Camera, plane distance 100. Most of these values are more or less defaults, and it all works fine, except for the mouse.

If both game and UI are drawn then the UI visually overlays the game, as desired, and visually the mouse events should go to the UI. Unfortunately in 3D space the game is closer to the camera and mouse events go to the game, not to the UI. This seems to be the documented working of the canvas raycaster, but it isn’t what I need.

The question is how to direct mouse events to the UI and prevent any mouse events reaching the game while the UI is visible.

On the Canvas there is a component called Graphic Raycaster

Make sure that Blocking Objects for this component is set to “None” and it should ignore any 3D elements.

https://docs.unity3d.com/Manual/Raycasters.html

https://docs.unity3d.com/Manual/script-GraphicRaycaster.html