Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5250,6 +5250,36 @@ public void Actions_CanAddBindingsToActions_ToExistingComposite()
composite.InsertPartBinding("Negative", "<Keyboard>/leftArrow");
composite.InsertPartBinding("Positive", "<Keyboard>/rightArrow");

ValidateCompositeBindingsOnAction(action);
}

[Test]
[Category("Actions")]
[Description("ISXB-494 Changing composite of action inside a map triggered exception that wasn't caught by previous test.")]
public void Actions_CanChangeBindingPart_ToExistingCompositeInActionMap()
{
var keyboard = InputSystem.AddDevice<Keyboard>();

var actionMap = new InputActionMap("Map");
var action = actionMap.AddAction("Action", InputActionType.Value, expectedControlLayout: "Axis");

action.AddCompositeBinding("Axis")
.With("Negative", "<Keyboard>/a")
.With("Positive", "<Keyboard>/d");

Assert.That(action.bindings, Has.Count.EqualTo(3));
Assert.That(action.controls, Is.EquivalentTo(new[] { keyboard.aKey, keyboard.dKey }));

var composite = action.ChangeCompositeBinding("Axis");

composite.InsertPartBinding("Negative", "<Keyboard>/leftArrow");
composite.InsertPartBinding("Positive", "<Keyboard>/rightArrow");

ValidateCompositeBindingsOnAction(action);
}

private void ValidateCompositeBindingsOnAction(InputAction action)
{
Assert.That(action.bindings, Has.Count.EqualTo(5));
Assert.That(action.bindings,
Has.Exactly(1).With.Property("isComposite").EqualTo(true).And.With.Property("isPartOfComposite").EqualTo(false).And.With
Expand Down
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Due to package verification, the latest version below is the unpublished version
however, it has to be formatted properly to pass verification tests.

## [Unreleased] - yyyy-mm-dd
- Fixed ArgumentNullException thrown when accessing Action's bindings after changing Composite part. [ISXB-494](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-494).

### Fixed
- Fixed default scroll speed in uGUI being slower than before. [ISXB-766](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-766)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ public BindingSyntax InsertPartBinding(string partName, string path)
throw new InvalidOperationException("Binding accessor must point to composite or part binding");

AddBindingInternal(m_ActionMap,
new InputBinding { path = path, isPartOfComposite = true, name = partName },
new InputBinding { path = path, isPartOfComposite = true, name = partName, action = m_Action?.name },
m_BindingIndexInMap + 1);

return new BindingSyntax(m_ActionMap, m_BindingIndexInMap + 1, m_Action);
Expand Down