Search Issue Tracker

Won't Fix

Votes

9

Found in

5.0.1f1

Issue ID

686693

Regression

No

IPointerExitHandler.OnPointerExit not triggered if object below pointer is destroyed or disabled

UI

-

Reproduction steps:
1. Open the user project "UnityBugs"
2. Open the scene "HoverBug"
3. Enter play mode
4. Hover the UI panel in the scene, with the pointer. Script on the panel logs messages OnPointerEnter and OnPointerExit
5. Click the panel, it will be destroyed
6. Notice that OnPointerExit was not called

Notes:
1. OnPointerExit is not called on the object that becomes inactive
2. OnPointerEnter is not called when an object becomes active under the pointer, until the pointer is moved

Comments (3)

  1. stargamingentertainment

    May 09, 2020 03:31

    FIX Example:

    If you have a script that implements from OnPointerEnter and OnPointerExit, attached to an object in the scene.

    what ever logic you have in the OnPointerExit, you can either execute that code or method in the
    OnDestroy()
    OnDisable()
    aswell as in the OnpointerExit

    e.g. i had this problem with a tooltip being showed. and i had the hide tooltip method being executed in the OnPointerExit.
    when the object was deleted the tooltip stayed up, which looked stupid.

    so i also called that hide method in destory and disable, so it will always get called

    Hope it helped
    Ricky

  2. DFSko

    Sep 25, 2015 12:37

    i have a button with code

    public void OnPointerClick(PointerEventData eventData)
    {
    Application.ExternalEval("window.open('/','_blank')");
    }

    after new tab opened, clicks on any place of document open new tabs

  3. emayberry

    Jun 19, 2015 14:12

    I got around this issue by testing for the cursor being over the game object in OnEnable/OnDisable, but it would be awesome for OnPointerEnter/Exit to work as expected when things are instantiated or destroyed under the cursor.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.