Skip to content

Commit 10f19c9

Browse files
committed
FIX: InputActionReference returning incorrect action when action has been called and cached, then Set and then calling action again.
1 parent a32fbdb commit 10f19c9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11576,6 +11576,24 @@ public void Actions_CanResolveActionReference_EvenAfterActionHasBeenRenamed()
1157611576
Assert.That(referencedAction, Is.SameAs(action));
1157711577
}
1157811578

11579+
[Test(Description = "https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1584")]
11580+
[Category("Actions")]
11581+
public void Actions_CanResolveActionReferenceAndThenSetItToAnotherAction()
11582+
{
11583+
var map = new InputActionMap("map");
11584+
var action1 = map.AddAction("action1");
11585+
var action2 = map.AddAction("action2");
11586+
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
11587+
asset.AddActionMap(map);
11588+
11589+
var reference = ScriptableObject.CreateInstance<InputActionReference>();
11590+
reference.Set(asset, "map", "action2");
11591+
Assert.That(reference.action, Is.SameAs(action2)); // Redundant, but important for test case
11592+
11593+
reference.Set(asset, "map", "action1");
11594+
Assert.That(reference.action, Is.SameAs(action1));
11595+
}
11596+
1157911597
[Test]
1158011598
[Category("Actions")]
1158111599
public void Actions_CanDisableAllEnabledActionsInOneGo()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private void SetInternal(InputActionAsset asset, InputAction action)
136136
m_Asset = asset;
137137
m_ActionId = action.id.ToString();
138138
name = GetDisplayName(action);
139+
m_Action = action;
139140

140141
////REVIEW: should this dirty the asset if IDs had not been generated yet?
141142
}

0 commit comments

Comments
 (0)