@@ -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