Input system not removing default bind after interactive rebind, unity
Asked Answered
M

1

6

I've been working on interactive rebinding in the input system of unity. But for some reason the old keybinds remain active. the default is wasd but if I rebind it in the menu to arrows arrows and wasd both move it. If I rebind after rebinding it to arrows to another one it uses wasd and the newly rebinded keys so it's not like it ain't removing it. It's more like it keeps the default active.

private void startRebinding(Button button, InputActionReference action, TMP_Text display, int bindingIndex = -1)
{
    button.interactable = false;
    display.text = waitingForInputText;
    action.action.Disable();
    playerInput.SwitchCurrentActionMap("UI");
    action.action.PerformInteractiveRebinding(bindingIndex)
        .OnMatchWaitForAnother(0.1f)
        .OnComplete(operation =>
        {
            display.text = InputControlPath.ToHumanReadableString(
                action.action.bindings[bindingIndex].effectivePath,
                InputControlPath.HumanReadableStringOptions.OmitDevice);

            operation.Dispose();
            button.interactable = true;

            playerInput.SwitchCurrentActionMap("Player");
            action.action.Enable();
        })
        .Start();
}

how can I make it so that it stops using the default keybind if you set a new keybind.

Multiple answered 19/9, 2022 at 9:23 Comment(0)
D
0

Try removing the existing binding before PerformInteractiveRebinding. Because PerformInteractiveRebinding won't remove the previous bindings.

if (bindingIndex >= 0) { action.action.ApplyBindingOverride(bindingIndex, string.Empty); }
Daryldaryle answered 27/8, 2024 at 9:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.