Is there a better way to prevent that a underlying 3d object (e.g. a cube) fires the OnMouseUp event when a UIElement is covering up this 3d element than EventSystem.IsPointerOverGameObject()?

Hi There,

I’m using the new unity UI system (Unity 4.6 and above) to create a strategy game. This game should have a GUI with some transparency “hovering” the 3d environment.

My problem is now that every time I click on a Button/Textbox (or something else from the UI system), it also fires the OnMouseUp events of the 3d Elements that should been hidden by that GUI. That could lead to odd behavior as the player starts to interact with elements that were not click directly but “through” the UI.

I found that I could check EventSystem.IsPointerOverGameObject() to check if the mouse is over an UI element. And, if so do nothing in my method. But well, I don’t want to do that as my object don’t need to know anything about the UI.

My Question is now: Does somebody know any “better” way to prevent that click-through rather than EventSystem.IsPointerOverGameObject()?

I’m thinking about something like that: I can tell the panel/UIElement to block 3d events. Maybe as a checkbox or a component that i can add via context menu if you want to have that optionally on any UI element???

Yes. Add a physics raycaster and implement the IClickHandler interface.