Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Ensure callback arrays are unlocked when invoked and returning true #1589

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,37 @@ public void PlayerInput_WhenOverridingDeviceLayout_LostDeviceShouldBeResolvedAnd
Assert.That(playerInput.devices[0], !Is.SameAs(gamepad)); // expected replacement (by design, not a requirement)
Assert.That(playerInput.devices[0].name, Is.EqualTo(gamepad.name));
}

[Test]
[Category("PlayerInput")]
public void PlayerInput_CanJoinPlayersThroughButtonPress_AfterAutoSwitchedPlayerDeleted()
{
var keyboard = InputSystem.AddDevice<Keyboard>();

var prefab = new GameObject();
prefab.SetActive(false);

var prefabPlayerInput = prefab.AddComponent<PlayerInput>();
prefabPlayerInput.actions = InputActionAsset.FromJson(kActions);
prefabPlayerInput.neverAutoSwitchControlSchemes = false;

var player = PlayerInput.Instantiate(prefab);

var gamepad = InputSystem.AddDevice<Gamepad>();

Press(gamepad.buttonSouth);

Object.DestroyImmediate(player);

var manager = new GameObject();
manager.SetActive(false); // Delay OnEnable() until we have all components.

var managerComponent = manager.AddComponent<PlayerInputManager>();

manager.SetActive(true);

Press(gamepad.buttonSouth);
}

// An action is either
// (a) button-like, or
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 @@ -12,6 +12,7 @@ however, it has to be formatted properly to pass verification tests.

### Fixed
- Fixed `ArgumentNullException` when opening the Prefab Overrides window and selecting a component with an `InputAction`.
- Fixed `ArgumentOutOfRangeException` when a Player Input that has been auto switched is deleted, and then a Player Input Manager attempts to join a new player.

## [1.4.3] - 2022-09-23

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public static bool InvokeCallbacksSafe_AnyCallbackReturnsTrue<TValue1, TValue2>(
try
{
if (callbacks[i](argument1, argument2))
{
callbacks.UnlockForChanges();
Profiler.EndSample();
return true;
}
}
catch (Exception exception)
{
Expand Down