Rebinding Keys Isn't reflected in existing controlSchemes

I’ve been working to migrate my game to the new Input system in order to have the ability to allow the players to Rebind all all the controls in my game, including existing axis(Vertical, Horizontal, ect…)
I’ve created my Input actions and configured them they way I believe they need to be configured.

And I’ve written code that allows me to read the inputs and react to them.

public class GameController : MonoBehaviour
{
  public InputMaster controls;
    bool pausePressed, deselectPressed, resetCameraPressed, restartPressed;

    public void Awake()
    {
        controls = new InputMaster();
        if (PlayerPrefs.HasKey("Controls"))
        {
            string controlsJSON = PlayerPrefs.GetString("Controls");
            controls.asset.LoadFromJson(controlsJSON);
        }
        controls.GameplayControls.Pause.performed += ctx => pausePressed = !pausePressed;
        controls.GameplayControls.Deselect.performed += ctx => deselectPressed = !deselectPressed;
        controls.GameplayControls.ResetCamera.performed += ctx => resetCameraPressed = !resetCameraPressed;
        controls.GameplayControls.Restart.performed += ctx => restartPressed = !restartPressed;

    }

    private void OnEnable()
    {
        controls.Enable();
    }

    private void OnDisable()
    {
        controls.Disable();
    }
}

   public class RTS_Camera : MonoBehaviour
    {
        public InputMaster controls;
        Vector2 movement;
        Mouse mouse;
        float mouseZoom;
        float screenWidth;
        float screenHeight;
        Vector2 center;
        float rotationInput;
        int zoomInput;
        private void Awake()
        {

            controls = new InputMaster();
            controls.CameraMovementControls.Movement.performed += ctx => movement = ctx.ReadValue<Vector2>();
            controls.CameraMovementControls.Rotate.performed += ctx => rotationInput = ctx.ReadValue<float>();
            controls.CameraMovementControls.Zoom.performed += ctx => zoomInput = Mathf.RoundToInt(ctx.ReadValue<float>());
            mouse = Mouse.current;
            mouseZoom = mouse.scroll.y.ReadValue();
            screenWidth = Screen.width;
            screenHeight = Screen.height;
            center = new Vector2(screenWidth / 2, screenHeight / 2);
        }
        private void OnEnable()
        {
            controls.Enable();
        }

        private void OnDisable()
        {
            controls.Disable();
        }
}

That all works as I would expect, However when I Rebind the controls Using the “Rebind Action UI” script (Transplanted into my project from the “Rebinding UI” Sample) the “ActionBindingText” Updates with the new controls but my Existing ‘InputMaster’ Objects still only respond to the original controls. This is my primary issue right now.

My end goal is to allow users to rebind controls and have those controls persist across plays (and between closing and reopening the game.)
The secondary issue I am having is that I have no idea how to “Save” the binds once they are set but I am assuming I’ll need to save off the .asset JSON and load based on the saved JSON. Is that the correct line of thinking?

I’ve been banging my head against this for quite awhile and I would appreciate any help you can provide.
Thanks
-Zachari Barnes

I’ve also Used the Input Debugger and It doesn’t appear that anything was remapped, but I don’t think overrides show on the Input Debugger by default.

I am having the same issue at the moment. I am using the RebindActionUI script from the sample, and it is updating the labels for the bindings, but the Actions and Bindings never seem to be modified. It is the same for the sample scene in the sample.

1 Like

@bilbaeno I’m seeing the same thing as you.
I’m on Unity 2019.2.11.f1

Could that be when it isn’t carrying the keybinding all the way into gameplay?

@Rene-Damm any thoughts? are we just missing a step here?

I have not set up any specific control schemes. Would that break the rebinding process in a way that doesnt throw an error code?

From what I’ve learned it isn’t supposed to change the actual binding in the asset, just set an override path for the binding.

But even so, I am not receiving input from the override binding.

1 Like

Yeah same.

I’ve been throwing in debug strings and when I throw them in OnActionChange in RebindActionUI.cs to try and expose the name for the action, I get null reference errors.

(pic of the error coming after my session loads)

I made a control scheme but that broke more things in my game and didnt fix the rebind not applying the override. Poking around the RebindActionUI.cs file i tried to find a place to plug in ApplyBindingOverride() but i can’t get all the info i need to pass along. Any one been able to figure this out?

1 Like

@Rene-Damm please save us, senpai <3

2 Likes

Sorry for my lateness here.

So, one general thing, with the C# generated wrappers, control schemes won’t do anything except with additional scripting. This is a gotcha that has caught many users unawares and something I would urgently like to have fixed after 1.0. Basically, whereas PlayerInput automatically takes care of device pairing and control scheme selection, you get none of this ATM with generated C# wrappers. Means that all bindings are active no matter what. You need to manually hook up that part.

var controls = new InputMaster();

// Restrict the controls to certain devices.
controls.devices = new InputDevice[] { Keyboard.current, Mouse.current };

// Restrict the controls to one control scheme.
controls.bindingGroup = InputBinding.MaskByGroup(controls.controlSchemes.First(x => x.name == "Keyboard&Mouse").bindingGroup);

Not pretty and not convenient. On the list for improvement.

Finally, we have an open bug where ApplyBindingOverride does not correctly flush out state on actions and old controls end up sticking around. I’ve started looking into it and a fix is expected to land in the next package after 1.0.0-preview.6. My suspicion is that this may be what you’re running into here.

As for saving rebinds, we have adding some more convenient wrappers on this on the list for after 1.0. I’ve posted about how to manually do this here .

2 Likes

Thank you for the info drop, @Rene-Damm

So does the RebindActionUI prefab actually call ApplyBindingOverride in its current iteration and it is just failing to flush old controls out?

or is there an insertion point where that function needs to be added?

1 Like

@Rene-Damm

For reference:
Issue occurs as detailed above on 1.0.0-preview.6

1 Like

@Rene-Damm bumping this to see if the potential fix for rebinding UI successfully impacting the player at runtime is slated to be included in the next update? Between the rebinding action UI prefab, the control binding Ui prefab in the tank demo scene, and a UI of my own I have not been able to apply a binding override so far. This would be a huge plus to get this on the next update (which hopefully is not delayed)

1 Like

Having a look. Will get back to you.

2 Likes

@Rene-Damm any luck so far?

2 Likes

Sorry to poke so much, @Rene-Damm

Any timeline on a fix for this? I just can’t figure out why none of my solutions work for this problem. I’d already used the Rebinding UI prefab provided in the Package Manager to set up my rebinding screen, so overcoming the hump of “I bind something, it updates the UI, but my controls dont effectively change for the player” would just make this who feature fall into place. Please save me <3 I’ve been blocked on this feature for a month now

1 Like

I have the same issue. The RebindUI sample scene doesn’t seem to actually rebind anything. @Rene-Damm should we just go back to using the old input system for the time being? Any estimate on when updates to the input system will be coming? I have other issues such as InputAction.performed or InputAction.cancelled not being fired OnButtonRelease after rebinding which could be related.

1 Like

Adding the code in UpdateBindingDisplay() logged me the new override path, but it still didn’t trigger any action with the new key binding. The old key binding still works…