Skip to content

Commit 82b53d6

Browse files
authored
FIX: UI Click events passing down to child objects (ISXB-857) (#1911)
* FIX: UI Click events passing down to child objects (ISXB-857) * Guard usages of pointerClick to 2020.1, when it was added.
1 parent d3f7053 commit 82b53d6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ however, it has to be formatted properly to pass verification tests.
2323
- Fixed DualSense Edge's vibration and light bar not working on Windows
2424
- Fixed Project-wide Actions asset failing to reload properly after deleting project's Library folder.
2525
- Fixed an issue where `System.InvalidOperationException` is thrown when entering PlayMode after deleting an ActionMap from Project-wide actions and later resetting it.
26+
- Fixed OnPointerClick events not propagating to child objects unless the child also handled OnPointerDown events [ISXB-857](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-857).
2627
- Fixed Input Actions Editor window resource leak that could result in unexpected exceptions [ISXB-865](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-865).
2728
- Fixed an issue where UI integration would throw exceptions when Project-wide Input Actions asset did not contain the implicitly required `UI` action map or was missing any of the required actions. Additionally this fix now also generates warnings in the console for any divergence from expected action configuration or lack of bindings in edit-mode.
2829

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,9 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
496496
// Set pointerPress. This nukes lastPress. Meaning that after OnPointerDown, lastPress will
497497
// become null.
498498
eventData.pointerPress = newPressed;
499+
#if UNITY_2020_1_OR_NEWER // pointerClick doesn't exist before this.
500+
eventData.pointerClick = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
501+
#endif
499502
eventData.rawPointerPress = currentOverGo;
500503

501504
// Save the drag handler for drag events during this mouse down.
@@ -516,7 +519,11 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
516519
// 2) StandaloneInputModule increases click counts even if something is eventually not deemed a
517520
// click and OnPointerClick is thus never invoked.
518521
var pointerClickHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
522+
#if UNITY_2020_1_OR_NEWER
523+
var isClick = eventData.pointerClick == pointerClickHandler && eventData.eligibleForClick;
524+
#else
519525
var isClick = eventData.pointerPress == pointerClickHandler && eventData.eligibleForClick;
526+
#endif
520527
if (isClick)
521528
{
522529
// Count clicks.
@@ -539,7 +546,11 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
539546

540547
// Invoke OnPointerClick or OnDrop.
541548
if (isClick)
549+
#if UNITY_2020_1_OR_NEWER
550+
ExecuteEvents.Execute(eventData.pointerClick, eventData, ExecuteEvents.pointerClickHandler);
551+
#else
542552
ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerClickHandler);
553+
#endif
543554
else if (eventData.dragging && eventData.pointerDrag != null)
544555
ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
545556

0 commit comments

Comments
 (0)