Skip to content

Commit 8d0e741

Browse files
committed
Update navigation state on move action swap
1 parent e388b9a commit 8d0e741

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,15 @@ public InputActionReference rightClick
13471347
public InputActionReference move
13481348
{
13491349
get => m_MoveAction;
1350-
set => SwapAction(ref m_MoveAction, value, m_ActionsHooked, m_OnMoveDelegate);
1350+
set
1351+
{
1352+
SwapAction(ref m_MoveAction, value, m_ActionsHooked, m_OnMoveDelegate);
1353+
// Because moveAction is the only action cached in the navigation state,
1354+
// we need to read new action's current value to avoid stale state from the previous action.
1355+
m_NavigationState.move = m_MoveAction?.action != null && m_MoveAction.action.enabled
1356+
? m_MoveAction.action.ReadValue<Vector2>()
1357+
: Vector2.zero;
1358+
}
13511359
}
13521360

13531361
/// <summary>

0 commit comments

Comments
 (0)