FIX: OnMouseUpAsButton dropped in Play mode on Game view focus change#2428
Open
LeoUnity wants to merge 2 commits into
Open
FIX: OnMouseUpAsButton dropped in Play mode on Game view focus change#2428LeoUnity wants to merge 2 commits into
LeoUnity wants to merge 2 commits into
Conversation
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.
…ef so MouseEvents tests compile versionDefines are scoped to the asmdef that declares them and do not propagate to referencing assemblies. UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS was declared only on the runtime asmdef (Unity.InputSystem.asmdef, Unity >= 6000.4.0a4), so the symbol was always undefined in the test assembly. The entire CoreTests_MouseEvents.cs file is gated by #if UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS, which meant the MouseEvents_CanReceive* tests (including the regression test that catches the OnMouseUpAsButton focus-update bug fixed in the previous commit) silently compiled out and never ran in CI. Mirror the runtime versionDefine on Unity.InputSystem.Tests.asmdef.
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop #2428 +/- ##
============================================
+ Coverage 58.58% 79.00% +20.42%
============================================
Files 738 765 +27
Lines 135831 140284 +4453
============================================
+ Hits 79570 110831 +31261
+ Misses 56261 29453 -26808 Flags with carried forward coverage won't be shown. Click here to find out more.
|
VeraMommersteeg
approved these changes
Jul 2, 2026
VeraMommersteeg
left a comment
Contributor
There was a problem hiding this comment.
looks like a simple fix to prevent it from reading from the wrong buffer. if the tests are all passing, then it lgtm. The only comment I would add is do we now have a test to cover this case so we catch this next time?
Pauliusd01
reviewed
Jul 2, 2026
| - Fixed an incorrect ArraysHelper.HaveDuplicateReferences implementation that didn't use its arguments right [ISXB-1792] (https://github.com/Unity-Technologies/InputSystem/pull/2376) | ||
| - 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. | ||
| - 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). | ||
| - 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. |
Collaborator
There was a problem hiding this comment.
A changelog entry is not needed as this was introduced in development and fixed in development
Pauliusd01
approved these changes
Jul 2, 2026
Pauliusd01
left a comment
Collaborator
There was a problem hiding this comment.
Seems simple, checked onMouse test scene as well as other mouse related ones in playmode and player and they work just fine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #93985 — input/isx-2424/add-focus-event-to-module introduced a regression to the MonoBehaviour.OnMouseUp due to the UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS not being defined in the test assembly. This PR addresses both the regression and ensuring the tests are now running.
Fix: legacy mouse-event pipeline driven from editor updates
Focus events (engine >= 6000.5.0a8) cause an
InputUpdateType.Editorupdate to run inPlay mode when the Game view focus changes.
FinalizeUpdatedrove the legacySendMouseEventspipeline from that editor update, wherePointer.currentreflects theeditor state buffer (position (0,0), not pressed). That produced a spurious mouse-up
that cleared the press target, so
OnMouseUpAsButton/OnMouseUpwere skipped on thereal release. Guard the legacy mouse send so it does not run for
InputUpdateType.Editorupdates (consistent with existing guards in this file). Focus-event delivery is
unaffected. Covered by
CoreTests.MouseEvents_CanReceiveOnMouseUpAsButton.Fix: MouseEvents tests were silently excluded from CI
UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTSwas declared as aversionDefineonlyon the runtime asmdef (
Unity.InputSystem.asmdef).versionDefinesare scoped to thedeclaring asmdef and do not propagate to referencing assemblies, so the symbol was
always undefined in the test assembly. The entire
CoreTests_MouseEvents.csfile isgated by
#if UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS— which meant everyMouseEvents_CanReceive*test (including the regression test that catches the bugabove) silently compiled out and never ran in CI on any editor version. This PR adds
the same versionDefine to
Unity.InputSystem.Tests.asmdef, mirroring how the siblingUNITY_INPUTSYSTEM_SUPPORTS_FOCUS_EVENTSdefine is already replicated across bothasmdefs.
Commits
FIX: OnMouseUpAsButton dropped in Play mode on Game view focus changeFIX: Add UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS to tests asmdef so MouseEvents tests compile