Seriously this needs to be on the top 10 FAQ of Unity and handled better.
I spent over 2 hours trying to get this to work using different techniques and they are not working. Googling, reading old posts etc.
The question is simple:
I have a UI, I have game objects on the ground. I don’t want to click the gameobject through the UI. How is there no definite way of solving this?
I have an InputManager that handles mouse clicks. When a click occurs on the UI I want it not to raycast through it!
What I tried so far:
-
Trying to block raycasts in my InputManager with EventSystem.current.IsPointerOverGameObject() return; … does not work. Still triggers the underlying gameobject that has “MouseUp”.
-
Tried using OnPointerClick on my gameobject. Does not work because it only works for UI.
Do I need EventSystem.current.IsPointerOverGameObject() on EVERY GAME OBJECT IN THE GAME?!
How do I solve this stupid issue?