Search Unity

Bug action.ChangeBinding(0).Erase() issue

Discussion in 'Input System' started by Poindexter, Feb 13, 2023.

  1. Poindexter

    Poindexter

    Joined:
    Aug 16, 2011
    Posts:
    21
    Hello,

    I'm implementing a system where all the actions and bindings are created at runtime. Now, is there a proper way to remove an action binding, because Erase seems to misbehave when an action has a single binding:

    Code (CSharp):
    1. InputAction action = new InputAction("MyAction", InputActionType.Value);
    2.  
    3. action.AddBinding(new InputBinding("Keyboard/a"));
    4.  
    5. Debug.Log($"Bindings count: {action.bindings.Count}"); // Prints 1
    6.  
    7. action.ChangeBinding(0).Erase();
    8.  
    9. Debug.Log($"Bindings count: {action.bindings.Count}"); // Also prints 1
    This seems like a bug, but am I missing something here? Is there another way to remove bindings? Do I have to refresh the action somehow after erasing a binding?
    Thanks in advance!
     
  2. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    116
    Looks like a bug. Thought that one was fixed a while ago. Which version are you on?
     
  3. Poindexter

    Poindexter

    Joined:
    Aug 16, 2011
    Posts:
    21
    I'm using Unity 2021.3.15f1 and Input System 1.4.4.