Search Issue Tracker

Fixed

Fixed in 2021.3.6f1, 2022.2.0b2, 2023.1.0a1

Votes

13

Found in

2021.3.5f1

2022.2.0a17

2023.1.0a1

Issue ID

UUM-2468

Regression

Yes

Button isn't highlighted when the mouse re-enters the Button's Child Image, which is set as Button's Target Graphic

--

-

Reproduction steps:
1. Open the attached project
2. Enter Play Mode
3. Hover the cursor over the white part of the Button in the Game View
4. Hover the cursor over the red square of the Button in the Game View
5. Hover the cursor back to the white part of the Button in the Game View
6. Observe the Button

Expected result: the white part of the Button should be highlighted
Actual result: the white part of the Button is not highlighted

Reproducible with: 2021.2.17f1, 2021.2.19f1, 2021.3.1f1, 2022.1.0f1, 2022.2.0a11
Not reproducible with: 2019.4.38f1, 2020.3.33f1, 2021.2.16f1

Note: this only happens when the Button's "Target Graphic" is set to a Button's Child Image GameObject and not to the Image Component attached to the Button

  1. Resolution Note (fix version 2023.1.0a1):

    uGUI: Reverted the default behavior for UI elements that implement IPointerEnter/Exit back to what it was before: when hovering a child component, it also sends the hovering event to the parent(s).

    Also added a field (sendPointerHoverToParent) in the BaseInputModule that can be set to false to change the behavior to: when hovering a child component, it doesn't send the hover event to the parent(s).

  2. Resolution Note (fix version 2022.2.0b2):

    uGUI: Reverted the default behavior for UI elements that implement IPointerEnter/Exit back to what it was before: when hovering a child component, it also sends the hovering event to the parent(s).

    Also added a field (sendPointerHoverToParent) in the BaseInputModule that can be set to false to change the behavior to: when hovering a child component, it doesn't send the hover event to the parent(s).

  3. Resolution Note (fix version 2021.3.6f1):

    uGUI: Reverted the default behavior for UI elements that implement IPointerEnter/Exit back to what it was before: when hovering a child component, it also sends the hovering event to the parent(s).
    Also added a field (sendPointerHoverToParent) in the BaseInputModule that can be set to false to change the behavior to: when hovering a child component, it doesn't send the hover event to the parent(s).

    Fixed in 2021.3.6f1

Comments (5)

  1. Froggie12

    Nov 24, 2022 16:58

    thanks for sharing

  2. aagnesKoa

    Jul 21, 2022 09:13

    As a note to any Unity dev, the changes in the ui module do not seem to appear in the documentation (https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/index.html) nor in the changelog, and it is still considered as "1.0.0"

  3. huantianad

    Jul 09, 2022 03:58

    Note that on the original issue (https://issuetracker.unity3d.com/issues/wrong-onenter-and-onexit-event-calls-when-hovering-over-ui-elements) that caused the original regression, they note that there was a typo in the issue, correcting this:

    Actual result: Log: Panel on exit; Image on enter; Panel on enter
    Expected result: Log: Panel on exit; Image on enter

    To this:

    Actual result: Log: Panel on exit; Image on enter; Panel on enter
    Expected result: Log: Image on enter

    When the mouse moves from the parent to the child, should the parent receive any event triggers at all? I don't know if just triggering the child's on enter would break anything.

  4. zeevasilyev

    Jun 08, 2022 14:42

    One more thing, this issue also has several other side-effects related to disabling the EventSystem. More specifically when a user calls EventSystem.current.enabled = false; The EventSystem tries calling OnPointerExit on whatever is currently hovered, however, because of this bug it fails and the hovered object will stay highlighted the whole time.

  5. zeevasilyev

    Jun 08, 2022 14:34

    This issue happens because of how the IPointerEnterHandler and IPointerExitHandler are invoked. Any child gameobject with enabled Raycast Target property will effectively steal the IPointerEnterHandler and IPointerExitHandler calls even if the child does not implement these. Moreover, the parent will never receive the IPointerEnter and IPointerExit callbacks again even after the cursor is moved from the child element back to the parent.

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.