Skip to content

Commit cc33939

Browse files
authored
FIX: Type of instance in array does not match expected type assertion (ISXB-282) (#1591)
1 parent 2a51b10 commit cc33939

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,30 @@ public void PlayerInput_WhenOverridingDeviceLayout_LostDeviceShouldBeResolvedAnd
23282328
}
23292329
";
23302330

2331+
[Test]
2332+
[Category("PlayerInput")]
2333+
public void PlayerInput_CanDisableAfterAssigningAction_WithControlSchemesAndInteractions()
2334+
{
2335+
var gamepad = InputSystem.AddDevice<Gamepad>();
2336+
var keyboard = InputSystem.AddDevice<Keyboard>();
2337+
2338+
var actions = ScriptableObject.CreateInstance<InputActionAsset>();
2339+
var action = actions.AddActionMap("map").AddAction("action", interactions: "Tap(duration=0.123)");
2340+
action.AddBinding("<Gamepad>/buttonSouth", groups: "Gamepad");
2341+
action.AddBinding("<Keyboard>/space", groups: "Keyboard");
2342+
actions.AddControlScheme("Gamepad")
2343+
.WithRequiredDevice<Gamepad>();
2344+
actions.AddControlScheme("Keyboard")
2345+
.WithRequiredDevice<Keyboard>();
2346+
actions.Enable();
2347+
2348+
var player = new GameObject();
2349+
var playerInput = player.AddComponent<PlayerInput>();
2350+
playerInput.defaultControlScheme = "Keyboard";
2351+
playerInput.actions = actions;
2352+
player.SetActive(false); // Should cause full rebinding and not assert
2353+
}
2354+
23312355
private struct Message : IEquatable<Message>
23322356
{
23332357
public string name { get; set; }

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
1313
### Fixed
1414
- Fixed `ArgumentNullException` when opening the Prefab Overrides window and selecting a component with an `InputAction`.
1515
- Fixed `{fileID: 0}` getting appended to `ProjectSettings.asset` file when building a project ([case ISXB-296](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-296)).
16+
- Fixed `Type of instance in array does not match expected type` assertion when using PlayerInput in combination with Control Schemes and Interactions ([case ISXB-282](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-282)).
1617

1718
## [1.4.3] - 2022-09-23
1819

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ internal bool LazyResolveBindings(bool fullResolve)
11891189
// created. Unfortunately, this can lead to some unnecessary re-resolving.
11901190

11911191
needToResolveBindings = true;
1192-
bindingResolutionNeedsFullReResolve = fullResolve;
1192+
bindingResolutionNeedsFullReResolve |= fullResolve;
11931193

11941194
if (s_DeferBindingResolution > 0)
11951195
return false;

0 commit comments

Comments
 (0)