- Home /
Unity 2021 LTS: IPointerEnterHandler is broken
Hey,
I've used 2021.1 for a while and I had a UI panel with a button inside it, as a child.
Both the panel and the button have their raycasts on, since both should be interactable.
I have a script with IPointerEnterHandler and IPointerExitHandler attached on the panel. Whenever you hover over the panel, the button inside it appears (so you can click it).
Now in 2021.1 it worked perfectly, I could hover over the panel and then click on the button. The IPointerEnterHandler considered the button raycast as its own - it was always like that.
However, in 2021.3, this seems to have changed. The same script and same UI no more work like that. The IPointerEnterHandler no more considers the button as its own raycast. Therefore, if you hover over the panel, it appears, but the moment you hover over the button it starts flickering. The button turns on and off every frame.
The issue is that when you hover over the button, you no longer hover over the panel, therefore the button disappears. But then you're again hovering over the panel, so the button reappears. A loop is created.
I couldn't find anything about this issue either in changelogs or in bug reports, therefore I'm asking here if anyone else has this issue and if anyone knows a fix for it.
Thanks
I have the same problem. My UI is based on the show/hide of certain panels, and from 2021.2.17 I can't show my panels with buttons, as @DenisWASD describes. Any help on how to work around this problem?
Thanks
For now, I've worked around it by checking where the mouse is on my screen and then activating the panel if the mouse is within rect's bounds. This works but the downside is that if something is over the panel, it will still appear since there's no hierarchy checking - only mouse position checking.
Answer by DenisWASD · 2 days ago
Looks like now you will need to do something like this:
public void OnPointerExit (PointerEventData eventData)
{
if (!eventData.fullyExited) return;
// Do stuff you've always done
}