Good Day,
this does work. If it is not working for you, remember again how the Input System works. If you hit play, it creates an Instance of the InputActions, this is also why you can edit them and why the changed values stay until you disable the InputActions again. If you are in Play mode and you try to do changes to the InputActionReference, this will not work, since you are trying to change the Reference instead of the instance that is created in runtime.
For me I clicked the small Button on the InputActionAsset to generate a C# Class.
In Runtime I then create an Instance of the PlayerInputActions:
InputActions ??= new PlayerInputActions();
When Changing the processor I need to get a reference to the InputActionReference that I want to change first:
[SerializeField] InputActionReference inputActionReference;
I then read the Name and ask the InputReader for the Action Instance it has created:
var inputActionName = inputActionReference.action.name;
if(inputReader == null) {
Debug.LogError("Rebind Handler is not set");
return;
}
// Get the current input Action associated with the Reference
var inputAction = inputActions.FindAction(inputActionName);
Up next I can either change the processor of the Action:
inputAction.ApplyParameterOverride("scaleVector2:x", 0f);
inputAction.ApplyParameterOverride("scaleVector2:y", 0f);
Or I can change the Processor of a Binding that is associated with a control scheme e.g.:
inputAction.ApplyParameterOverride("scaleVector2:x", 0f, InputBinding.MaskByGroup("Mouse"));
inputAction.ApplyParameterOverride("scaleVector2:y", 0f, InputBinding.MaskByGroup("Mouse"));
But remember, now we are just editing the modifiers of the Action. If you want to edit the modifiers of lets say Gamepad bindigs only, we need to
- Identify the bindings, Important for this variant the Gamepad Control Scheme Box needs to be checked in your InputAsset
var inputDeviceActionBindings = inputAction.bindings.Where(binding =>
binding.groups != null && binding.groups.Contains("Gamepad")).ToArray();
- Now we can directly edit all the gamepad bindings we have for this processor!
foreach (var inputDeviceActionBinding in inputDeviceActionBindings) {
inputAction.ApplyParameterOverride("scaleVector2:x", "0", inputDeviceActionBinding);
inputAction.ApplyParameterOverride("scaleVector2:y", "0", inputDeviceActionBinding);
}
If you want to get the values, lets say show them to the user on a slider, it would look like this:
foreach (var inputDeviceActionBinding in inputDeviceActionBindings) {
var xScale = inputAction.GetParameterValue("scaleVector2:x", inputDeviceActionBinding);
var yScale = inputAction.GetParameterValue("scaleVector2:y", inputDeviceActionBinding);
if (xScale != null)
if (yScale != null)
Debug.Log($"<color=blue>Binding: {inputDeviceActionBinding.path}, X: {xScale.Value}, Y: {yScale.Value}</color>");
}