Search Unity

Trouble trying to rebind a dpad composite

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

  1. smasson99

    smasson99

    Joined:
    Oct 1, 2017
    Posts:
    10
    Hi! I have this code that works greatly with simple actions, but when it comes to composites the rebind just never happens. I have to cancel every time while it works very well with simple actions. Could you please tell
    me what is wrong with this?

    Code (CSharp):
    1. private void RebindAction(InputAction actionToRebind)
    2.         {
    3.             actionToRebind.Disable();
    4.  
    5.             rebindingOperation?.Dispose();
    6.             rebindingOperation = actionToRebind
    7.                 .PerformInteractiveRebinding()
    8.                 .WithTargetBinding(onKeyBinderClicked.KeyBindingProfile.GetBindingIndex())
    9.                 .WithControlsExcluding("<Mouse>/position")
    10.                 .WithControlsExcluding("<Mouse>/delta")
    11.                 .OnMatchWaitForAnother(0.1f)
    12.                 .OnCancel(OnRebindCancelled)
    13.                 .OnComplete(OnRebindCompleted)
    14.                 .Start();
    15.         }
    16.  
    17. [...]
    18.  
    19. public virtual int GetBindingIndex()
    20. {
    21.     return 0;
    22. }
    23.  
    24. [...]
    25.  
    26. public override int GetBindingIndex()
    27. {
    28.     return actionReference.action.bindings.IndexOf(x =>
    29.         x.name == compositeName);
    30. }
    31.  
    32.  
    Thanks in advance!
    Sam.
     
  2. smasson99

    smasson99

    Joined:
    Oct 1, 2017
    Posts:
    10
    This line fixes the issue for me :
    rebindingOperation.WithExpectedControlType("Button");