Skip to content

Commit 99f6a16

Browse files
committed
FIX: OnMouseUpAsButton dropped in Play mode on Game view focus change
Focus events (engine >= 6000.5.0a8) cause an InputUpdateType.Editor update to run in Play mode when the Game view focus changes. FinalizeUpdate drove the legacy SendMouseEvents pipeline from that editor update, where Pointer.current reflects the editor state buffer (position (0,0), not pressed). That produced a spurious mouse-up that cleared the press target, so OnMouseUpAsButton/OnMouseUp were skipped on the real release. Guard the legacy mouse send so it does not run for InputUpdateType.Editor updates (consistent with existing guards in this file). Focus-event delivery is unaffected. Covered by CoreTests.MouseEvents_CanReceiveOnMouseUpAsButton.
1 parent 6610131 commit 99f6a16

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3131
- Fixed an incorrect ArraysHelper.HaveDuplicateReferences implementation that didn't use its arguments right [ISXB-1792] (https://github.com/Unity-Technologies/InputSystem/pull/2376)
3232
- Fixed `InputAction.IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` using a `ButtonControl`'s `pressPoint` when a binding also had an explicit `PressInteraction` with its own `pressPoint`, which could make those APIs disagree with the interaction's press and release behavior. Action-level press APIs now follow the interaction threshold when both are set explicitly.
3333
- Fixed `IndexOutOfRangeException` in `InputDeviceBuilder` when connecting an HID gamepad whose report descriptor declares a hat switch with Report Size 8 (e.g. ESP32-BLE-Gamepad). The HID layer now anchors the hat's directional sub-controls to the hat's own byte instead of letting the layout system auto-allocate a fresh byte for each [UUM-143659](https://jira.unity3d.com/browse/UUM-143659).
34+
- Fixed `OnMouseUpAsButton` and `OnMouseUp` being dropped in Play mode when the Game view's focus changes between a press and its release on Unity 6000.5.0a8 and newer. The legacy `SendMouseEvents` pipeline is no longer driven from `InputUpdateType.Editor` updates, which read the editor state buffer (position (0,0), not pressed) and produced a spurious mouse release that cleared the press target.
3435

3536
### Changed
3637
- Action-level `IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` for bindings to `Vector2Control` / `StickControl` no longer consult a per-control `pressPoint` on the vector (that field was removed). Use a `Press` interaction to set a custom threshold, or rely on `defaultButtonPressPoint`.

Packages/com.unity.inputsystem/InputSystem/Runtime/InputManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4069,7 +4069,9 @@ private void FinalizeUpdate(InputUpdateType updateType)
40694069
//send pointer data to backend for OnMouseEvents
40704070
#if UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS
40714071
var pointer = Pointer.current;
4072-
if (pointer != null && pointer.added && gameIsPlaying)
4072+
// Skip during InputUpdateType.Editor: pointer reads the editor state buffer (position (0,0), not pressed),
4073+
// which would emit a spurious release and drop OnMouseUp/OnMouseUpAsButton on the real release.
4074+
if (pointer != null && pointer.added && gameIsPlaying && updateType != InputUpdateType.Editor)
40734075
NativeInputSystem.DoSendMouseEvents(pointer.press.isPressed, pointer.press.wasPressedThisFrame, pointer.position.x.value, pointer.position.y.value);
40744076
#endif
40754077
m_CurrentUpdate = default;

0 commit comments

Comments
 (0)