InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

Disabling and re-enabling an action stops taking input from the keyboard

Open MetaflameDragon opened this issue 7 years ago • 2 comments

I found that calling Disable() and Enable() on an action stops taking keyboard input for that action (other actions still work correctly).

For example, I have an action Inventory.Open hooked to E on the keyboard and a joystick button. When the player pauses the game, I call Inventory.Open.Disable(), which blocks the input completely. I then call Inventory.Open.Enable(), which should restore the Action back to its enabled state, but now only the joystick input is accepted, and pressing E does nothing.

I have also verified this for a Vector2 Action (movement) bound to a joystick and composite WASD: after a Disable() and Enable(), only the joystick works, and WASD stops responding.

Pause.InventoryLock.OnLocked      += controls.Inventory.Open.Disable;
Pause.InventoryLock.OnLocked      += DisableHotbar;
Pause.InventoryLock.OnUnlocked    += controls.Inventory.Open.Enable;
Pause.InventoryLock.OnUnlocked    += EnableHotbar;

Simple code example, I bind the Enable and Disable methods to events.

MetaflameDragon avatar Apr 18 '19 15:04 MetaflameDragon

I'm 98% certain this is the same bug as #538. Feel free to add your vote here: https://issuetracker.unity3d.com/issues/scripting-input-action-fails-to-re-enable-after-disabled, so our dev can prioritize bug fixing. Thanks!

JiaUnity avatar Apr 20 '19 00:04 JiaUnity

Closing for this bug is filed.

JiaUnity avatar Apr 25 '19 21:04 JiaUnity