Skip to content

Commit 9d92134

Browse files
committed
Address PR feedback to ensure the m_CurrentUpdate is cleared in the finally block
1 parent 53336a8 commit 9d92134

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ internal void OnFocusChanged(bool focus)
3535
m_IsHandlingFocusChange = true;
3636
m_ApplicationHadFocus = !focus;
3737

38+
#if UNITY_EDITOR
39+
var shouldClearCurrentUpdateInFinally = false;
40+
#endif
41+
3842
try
3943
{
4044
#if UNITY_EDITOR
@@ -48,7 +52,6 @@ internal void OnFocusChanged(bool focus)
4852

4953
var runInBackground =
5054
#if UNITY_EDITOR
51-
5255
// In the editor, the player loop will always be run even if the Game View does not have focus. This
5356
// amounts to runInBackground being always true in the editor, regardless of what the setting in
5457
// the Player Settings window is.
@@ -68,11 +71,11 @@ internal void OnFocusChanged(bool focus)
6871
}
6972

7073
#if UNITY_EDITOR
71-
7274
// Set the current update type while we process the focus changes to make sure we
7375
// feed into the right buffer. No need to do this in the player as it doesn't have
7476
// the editor/player confusion.
7577
m_CurrentUpdate = m_UpdateMask.GetUpdateTypeForPlayer();
78+
shouldClearCurrentUpdateInFinally = true;
7679
#endif
7780

7881
if (!focus)
@@ -123,13 +126,14 @@ internal void OnFocusChanged(bool focus)
123126
ResetDevice(device);
124127
}
125128
}
126-
127-
#if UNITY_EDITOR
128-
m_CurrentUpdate = InputUpdateType.None;
129-
#endif
130129
}
131130
finally
132131
{
132+
#if UNITY_EDITOR
133+
if (shouldClearCurrentUpdateInFinally)
134+
m_CurrentUpdate = InputUpdateType.None;
135+
#endif
136+
133137
m_IsHandlingFocusChange = false;
134138
}
135139
}

0 commit comments

Comments
 (0)