BrainByte
Topic Author
Posts: 8
Joined: 09 Mar 2019, 09:34

How to prevent mouse clicks from being processed by objects behind the GUI in Unity

18 Dec 2019, 22:53

Hi,

NoesisGui Unity

I have a button on a grid and I have MouseEnter and MouseLeave events attached to the Grid

I'm detecting onMouseEnter and onMouseLeave so that I can disable and enable click behaviour on objects under the GUI and I'm experience odd click events

I get a mouseEnter when I move the mouse over the UI and then when I click a button I get a mouseEnter followed by a mouseLeave as also noted in post

viewtopic.php?t=961#p5242

Everything works as expected when I click everything other than the button but the button fires an enter and leave when I'm still over the grid so my code that disables the click on objects underneath the UI is being disabled by these two additional events.

Any ideas or work arounds would be most appreciated.
 
BrainByte
Topic Author
Posts: 8
Joined: 09 Mar 2019, 09:34

Re: How to prevent mouse clicks from being processed by objects behind the GUI in Unity

19 Dec 2019, 12:33

I was using Input.GetMouseButtonUp on the gameObject which was correctly triggering after the Grid mouse events thus was preventing me from reacting to the mouse at the appropriate time.

I've switched to GetMouseDown which fires while the UI is visible and so I can use the mouseEnter and mouseLeave events

Who is online

Users browsing this forum: Google [Bot] and 0 guests