Exclude Specific GUI Elements from EventSystem.IsPointerOverGameObject


My game is mouse controlled and use raycasting to detect where the user clicked. Additionally i use EventSystem.IsPointerOverGameObject to detect if the mouse is over my main GUI Elements so i dont click “through” them. That works fine.

Now i have a few more GUI Elements like damageTexts or healthbars. I dont want them to block the mouse clicks. Is there any way to exclude them from IsPointerOverGameObject?
Or is there any other way to solve my problem?

Thanks in advance

Not the prettiest solution … but still:
I had the same problem and couldn’t get any solution to work.
I ended up setting a global boolean variable to use instead of IsPointerOverGameObject() - something like “isOverBlockingElement”, then I set it to true on OnMouseEnter and to false on OnMouseExit events of potentially blocking GUI elements.