UI Stops Blocking Raycasts When You Click Off Game

So I have a 2D game using the Standalone Input Module for the Event System.

I have discovered that if I click off my game, and click back onto the game, that initial click back onto the game doesn’t seem to work properly.

Take the following example:
I have a canvas with an image (set as a raycast target) and a canvas group object set to ‘alpha: 1, blocks raycasts: true, interactable: true’. What this means, is that in theory I can click on the image and not also click on any gameobjects behind the UI element. While this works in practice most of the time, if I click off my game (which is set to run in the background), as soon as I click back that first click no longer gets blocked by the UI and instead ignores the image and selects the gameobject underneath.

Again, from when the game launches onward everything works as expected…so long as you don’t click off the game and come back. As soon as you’ve clicked back everything continues to work normally, it’s just that very first click that seems to defy the rules of the event system.

Boost