Author Topic: Unhovering when over UI  (Read 156 times)

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Unhovering when over UI
« on: May 30, 2020, 02:59:40 AM »
Hi,

MarkerClickHandler.OnMarkerMouseExit wonīt get called when the mouse goes over an overlapping UI Panel, even if "Respect Other UI" is checked.
Is this mine fault or an intended behaviour or a bug? What would be the best way to work around that?

Attachment: The dark blue thingy is the panel, the red hexagon is the marker with the click handler. The collider is sized after the hexagon.
The mouse goes from the hover over the panel and leaves the hexagon, but the hover stays. Clicks are blocked by the UI, so generally "Respect Other UI" does work for me.

Thanks in advance :-)

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Unhovering when over UI
« Reply #1 on: May 31, 2020, 04:36:52 AM »
Update:

Iīve settled down to custom markers and a custom marker click handler. I want to spawn my markers under custom parents to gain more flexibility.
I will try to implement the wanted unhovering-behaviour in my custom marker click handler.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Unhovering when over UI
« Reply #2 on: May 31, 2020, 04:56:45 AM »
Try latest beta. The MarkerClickHandler component now exposes a Respect Other UI property which defaults to false so it should unhover as soon as pointer exit the marker, regardless of the map Respect Other UI setting.

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Unhovering when over UI
« Reply #3 on: May 31, 2020, 04:59:34 AM »
Thank you very much, Iīll let you know if it works.  :)

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Unhovering when over UI
« Reply #4 on: May 31, 2020, 08:18:22 AM »
Ok, updating was successful. Now Iīve the decision between two behaviours:

-Unhover when the mouse leaves the sprite rect AND is over the UI (Respect Other UI = false)
-Donīt unhover at all when you enter an UI while hovering a marker

What I would need is a third behaviour: Unhover (and donīt allow clicks!) when the cursor moves over an UI element, even if the cursor is inside the sprite rect.


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Unhovering when over UI
« Reply #5 on: June 01, 2020, 09:54:52 AM »
Try the following. In MarkerClickHandler.cs, add the line below to SpriteRectContainsPointer() method:

Code
 bool SpriteRectContainsPointer() {
            // Check if cursor location is inside marker rect
            if (map == null)
                return false;
            if (map.mouseIsOverUIElement) return false;
            Vector3 cursorLocation;
...

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Unhovering when over UI
« Reply #6 on: June 01, 2020, 02:32:44 PM »
Will try that tomorrow, thanks.

tfh

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Unhovering when over UI
« Reply #7 on: June 02, 2020, 12:18:15 PM »
Worked perfectly, thanks!