Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feedback WithCancelingThrough not accepting more than one binding

Discussion in 'Input System' started by BorjaFAC90, Aug 13, 2020.

  1. BorjaFAC90

    BorjaFAC90

    Joined:
    Jul 21, 2020
    Posts:
    8
    Hi all,

    I've been using the new input system for a couple days or so, and I am just figuring out how should everything work. This time, I am facing a problem on my rebinding system. I support gamepad and keyboard, and when I use the PerformInteractiveRebinding function from the InputAction, I see that only the last WithCancelingThrough is the one that matters, as repeated calls to this will override the info (from the docs: Note that every rebind operation has only one such path. Calling this method repeatedly will overwrite the path set from prior calls). Any workaround in my case, where I want to have more than one possible cancel button (one for keyboard and the other for gamepad)?

    Thanks!
     
    Szappy and CGDever like this.
  2. Szappy

    Szappy

    Joined:
    Feb 3, 2020
    Posts:
    1
    Hey just wondering if you found a solution to this issue as I seem to have it
     
  3. Memoriesin8bit

    Memoriesin8bit

    Joined:
    Feb 20, 2020
    Posts:
    10
    @Szappy I ended up using a dirty little hack. Instead of using WithCancelingThrough, I intercepted certain cancel keys in the OnComplete call like this:
    Code (CSharp):
    1. if (action.bindings[bindingIdx].overridePath == "<Gamepad>/select" || action.bindings[bindingIdx].overridePath == "<Keyboard>/escape")
    2.             InputActionRebindingExtensions.ApplyBindingOverride(action, bindingIdx, new InputBinding{overridePath = ""});
    That way both the gamepad select as well as keyboard escape keys would immediately save the binding as empty.