Skip to content

Commit 747767f

Browse files
authored
FIX: Fixed ISubmitHandler.OnSubmit event processing when operating in Manual Update mode (case ISXB-1141) (#2041)
* [Input System] Fix for event processing when operating in Manual Update mode (case ISXB-1141) * [Input System] Added CHANGELOG.md entry for ISubmitHandler.OnSubmit fix (ISXB-1141)
1 parent 43efc3b commit 747767f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ however, it has to be formatted properly to pass verification tests.
1515
- Reverted changes from 0ddd534d8 (ISXB-746) which introduced a regression [ISXB-1127](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1127).
1616
- Fixed `ArgumentNullException: Value cannot be null.` during the migration of Project-wide Input Actions from `InputManager.asset` to `InputSystem_Actions.inputactions` asset which lead do the lost of the configuration [ISXB-1105](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1105)
1717
- Fixed pointerId staying the same when simultaneously releasing and then pressing in the same frame on mobile using touch. [ISXB-1006](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-845)
18+
- Fixed ISubmitHandler.OnSubmit event processing when operating in Manual Update mode (ISXB-1141)
1819

1920
### Changed
2021
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086)

Packages/com.unity.inputsystem/InputSystem/Actions/InputAction.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,16 @@ public unsafe bool IsInProgress()
11861186
return false;
11871187
}
11881188

1189+
private int ExpectedFrame()
1190+
{
1191+
// Used by the Was<XXX>ThisFrame() methods below.
1192+
// When processing events manually the event processing will happen one frame later.
1193+
//
1194+
int frameOffset = InputSystem.settings.updateMode == InputSettings.UpdateMode.ProcessEventsManually ? 1 : 0;
1195+
int expectedFrame = Time.frameCount - frameOffset;
1196+
return expectedFrame;
1197+
}
1198+
11891199
/// <summary>
11901200
/// Returns true if the action's value crossed the press threshold (see <see cref="InputSettings.defaultButtonPressPoint"/>)
11911201
/// at any point in the frame.
@@ -1236,7 +1246,7 @@ public unsafe bool WasPressedThisFrame()
12361246
{
12371247
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12381248
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1239-
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1249+
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
12401250
}
12411251

12421252
return false;
@@ -1285,7 +1295,7 @@ public unsafe bool WasReleasedThisFrame()
12851295
{
12861296
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12871297
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1288-
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1298+
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
12891299
}
12901300

12911301
return false;
@@ -1344,7 +1354,7 @@ public unsafe bool WasPerformedThisFrame()
13441354
{
13451355
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
13461356
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1347-
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1357+
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
13481358
}
13491359

13501360
return false;
@@ -1417,7 +1427,7 @@ public unsafe bool WasCompletedThisFrame()
14171427
{
14181428
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
14191429
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1420-
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1430+
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
14211431
}
14221432

14231433
return false;

0 commit comments

Comments
 (0)