Please explain the Graphics Raycaster

I’m making a small game for the first time and enjoying it thus far. The only thing that keeps bothering me is that I can’t find a human explanation of what the graphics raycaster does. What’s the blocking mask, what are the blocking objects etc? Should I mask the things I want clicked or the things I don’t want clicked?

As an example I have the following screenshot: http://i.imgur.com/6nkVY7b.png

The overlayCanvas has the pinkish square on the top in it and the button “Button” on the pink square. Nonetheless, the whole bloody canvas is clickable instead of just the button and the pink square. Which means that all interaction seized because the canvas is on a “topLayer” which has its own camera.

The Square+button in the overlayCanvas are on “topLayer” aswell.
But I just want the button and the pink square(and what’s in it) clickable because the game is relying on clicks on the background image.

The ‘Blocks Raycasts’ setting on your canvas group is the problem here and is why the whole canvas has become clickable. Either turn that off or have it just on the buttons and not the entire canvas.

I actually had the opposite problem earlier of the buttons not blocking raycast and allowing the geometry beneath them to be clicked so I’ll post a solution I found to that here too in case you need it.

    void OnMouseDown()
    {
        if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() == false)
        {
        //Do something
        }
     }

Using that condition on the geometry beneath the UI buttons prevents it from being clicked if the cursor is over the button without having to mess around with canvas groups.