From 550cf70a90fb91e66579a3da41dd77aec73b4094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Mon, 7 Jul 2025 12:14:31 +0300 Subject: [PATCH] Revert #1982 but leave commented code --- .../Plugins/UI/InputSystemUIInputModule.cs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs index 2ce58a635a..375f2546c9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs @@ -2072,13 +2072,13 @@ private bool RemovePointerAtIndex(int index) { Debug.Assert(m_PointerStates[index].eventData.pointerEnter == null, "Pointer should have exited all objects before being removed"); - // We don't want to release touch pointers on the same frame they are released (unpressed). They get cleaned up one frame later in Process() - ref var state = ref GetPointerStateForIndex(index); - if (state.pointerType == UIPointerType.Touch && (state.leftButton.isPressed || state.leftButton.wasReleasedThisFrame)) - { - // The pointer was not removed - return false; - } + // // We don't want to release touch pointers on the same frame they are released (unpressed). They get cleaned up one frame later in Process() + // ref var state = ref GetPointerStateForIndex(index); + // if (state.pointerType == UIPointerType.Touch && (state.leftButton.isPressed || state.leftButton.wasReleasedThisFrame)) + // { + // // The pointer was not removed + // return false; + // } // Retain event data so that we can reuse the event the next time we allocate a PointerModel record. var eventData = m_PointerStates[index].eventData; @@ -2350,13 +2350,19 @@ private void FilterPointerStatesByType() // We have input on a mouse or pen. Kill all touch and tracked pointers we may have. for (var i = 0; i < m_PointerStates.length; ++i) { - ref var state = ref GetPointerStateForIndex(i); - // Touch pointers need to get forced to no longer be pressed otherwise they will not get released in subsequent frames. - if (m_PointerStates[i].pointerType == UIPointerType.Touch) - { - state.leftButton.isPressed = false; - } - if (m_PointerStates[i].pointerType != UIPointerType.MouseOrPen && m_PointerStates[i].pointerType != UIPointerType.Touch || (m_PointerStates[i].pointerType == UIPointerType.Touch && !state.leftButton.isPressed && !state.leftButton.wasReleasedThisFrame)) + // ref var state = ref GetPointerStateForIndex(i); + // // Touch pointers need to get forced to no longer be pressed otherwise they will not get released in subsequent frames. + // if (m_PointerStates[i].pointerType == UIPointerType.Touch) + // { + // state.leftButton.isPressed = false; + // } + // if (m_PointerStates[i].pointerType != UIPointerType.MouseOrPen && m_PointerStates[i].pointerType != UIPointerType.Touch || (m_PointerStates[i].pointerType == UIPointerType.Touch && !state.leftButton.isPressed && !state.leftButton.wasReleasedThisFrame)) + // { + // if (SendPointerExitEventsAndRemovePointer(i)) + // --i; + // } + + if (m_PointerStates[i].pointerType != UIPointerType.MouseOrPen) { if (SendPointerExitEventsAndRemovePointer(i)) --i;