Search Issue Tracker
Fixed in 0.3.0-preview
Votes
0
Found in [Package]
0.0.9-preview
Issue ID
1093783
Regression
No
[Input Action] Action binding doesn't refresh with ApplyBindingOverride() during runtime
Migrated bug from GitHub: https://github.com/Unity-Technologies/InputSystem/issues/247
I want a way to let users select a different button to trigger the fire action. Take the code example below, when I press num 1 then the original A key will be replaced with W key for that action.
public class TestBindingOverride: MonoBehaviour
{
public InputAction fireAction;
public void Awake()
{
fireAction = new InputAction(name: "fire", binding: "<Keyboard>/a");
fireAction.performed +=
ctx =>
{
Debug.Log("fire!");
};
}
public void OnEnable()
{
fireAction.Enable();
}
public void OnDisable()
{
fireAction.Disable();
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
fireAction.Disable();
fireAction.ApplyBindingOverride(path: "<Keyboard>/a", newBinding: "<Keyboard>/w");
fireAction.Enable();
}
}
}
The problem is that the binding override doesn't apply immediately, and I found it refreshed when any device is discovered and added to the system.
This is when I press num 1 to call ApplyBindingOverride(), but nothing happened. The A key still triggers the fire action but W key doesn't. (See Image_1)
When I turn on my Vive tracker (any other device will do), the system updates the binding from A key to W key. Now W key triggers the fire action but A key doesn't. (See Image_2)
Any idea on how to fix it? Or is there any better way to do this? Thanks.
Rene-Damm commented on Sep 13
Confirmed. InputActionRebindingExtensions isn't flushing resolved data.
Partial fix in 07b5979. Needs some related changes to happen to catch all the cases.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
Add comment