Search Unity

In game key binding option menu

Discussion in 'Input System' started by PlasMania, Aug 23, 2019.

  1. PlasMania

    PlasMania

    Joined:
    Aug 11, 2014
    Posts:
    15
    Hey, so I've just switched to the new input system, and I was wondering how to make the in game key-binding option menu, basically I would like to know:
    1. How to get a variable with the key name to display the current key on the screen
    2. How to edit the current binding, to a new key
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    If you have an action `m_Action` containing the binding you want to change:

    1. Try something like
    InputControlPath.ToHumanReadableString(m_Action.bindings[0].effectivePath);

    2. Try something like
    Code (CSharp):
    1.  m_Action.PerformInteractiveRebinding()
    2.             .WithControlsExcluding("<Mouse>/position")
    3.             .WithControlsExcluding("<Mouse>/delta")
    4.             .OnMatchWaitForAnother(0.1f)