PerformInteractiveRebinding freezes when trying to recognize new binding

Doing a simple Remapping script (trying to follow exactly as the Tanks demo, but boiling it down to the bare minimum).

I boiled it down to these main componentes:

  • A public InputActionReference that is set, via the Inspector, to the Action that will be remapped
  • A private InputAction variable that recieves the reference’s action parametr
  • A public Remapping method has the InputAction variable call PerformInteractiveRebinding().Start() with a OnComplete callback set.
  • The call is saved to a InputActionRebindingExtensions.RebindingOperation variable
  • When the OnComplete callback is called, a Dispose() method should be called to the InputActionRebindingExtensions.RebindingOperation variable I saved earlier. This is also when I can update the UI to show the new key
  • The script is added to the button and the public InputActionReference is set
  • The public “Remap” method is set as the onClick to a UI button

This the code of my script, nothing really fancy but It never calls the “ButtonRemapComplete” function:

using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class RemappingScript : MonoBehaviour
{
    public InputActionReference reference;
    InputAction action;
    private Text m_Text;
    private Button m_Button;
    private InputActionRebindingExtensions.RebindingOperation m_RebindOperation;

    void Start()
    {
        // Debug.Log(reference);
        action = reference.action;
        m_Button = GetComponentInChildren<Button>();
        m_Text = m_Button.GetComponentInChildren<Text>();
        m_Text.text = InputControlPath.ToHumanReadableString(action.bindings[0].effectivePath);
    }

    public void RemapKey()
    {
        m_Button.enabled = false;
        m_Text.text = "Press the new key";
        m_RebindOperation = action.PerformInteractiveRebinding()
        .WithControlsExcluding("<Mouse>/position")
        .OnMatchWaitForAnother(0.1f)
        .OnComplete(operation => ButtonRemapComplete());
        m_RebindOperation.Start();
    }

    public void ButtonRemapComplete()
    {
        Debug.Log("OK!");
        m_Text.text = InputControlPath.ToHumanReadableString(action.bindings[0].effectivePath);
        m_RebindOperation.Dispose();
        m_RebindOperation = null;
        m_Button.enabled = true;
    }
}

When I click the button, the RemapKey function is called, even the UI changes to display “Press the new key”. But it goes unresponsive after that. It doesn’t recognize my inputs and all other actions from my inputactions file stop working (I assume that’s because it’s waiting to detec the new key)

Am I doing something wrong here? Is something missing?

Hey Christian,

did you find a solution to the problem?

Thanks for your reply.