I’ve been working with the Input System rebinding features. One thing I’m trying to implement is the ability to switch between “Simple” and “Combo” ways of activating a signature attack (either a dedicated button, or a button + the main attack button, respectively). This function, UpdateSignatureActivation
, is invoked in one of my rebind button’s Stop Events.
public void UpdateSignatureActivation()
{
if (inputActions != null)
{
string controlSchemeName = GetControlSchemeName();
InputAction mainAttack = inputActions.Player.MainAttack;
InputAction signatureAttack = inputActions.Player.SignatureAttack;
RebindActionUI attackButton = null;
RebindActionUI signatureButton = null;
foreach (RebindActionUI button in buttons)
{
if (button.actionReference.action.id == mainAttack.id)
attackButton = button;
else if (button.actionReference.action.id == signatureAttack.id)
signatureButton = button;
}
if (signatureButton != null)
{
InputAction sigAction = signatureButton.actionReference.action;
int startIndex = sigAction.GetBindingIndex(InputBinding.MaskByGroup(controlSchemeName));
if (settings.GetSignatureActivationMode() == ControlPresetSettings.SignatureActivation.Simple)
{
if (sigAction.bindings[startIndex].effectivePath != "") // There's a "true" composite here
{
string originalModifierPath = sigAction.bindings[startIndex + 1].effectivePath;
Debug.Log(sigAction.bindings[startIndex - 1].GetNameOfComposite());
sigAction.ChangeCompositeBinding(sigAction.bindings[startIndex - 1].GetNameOfComposite())
.WithGroup(controlSchemeName)
.InsertPartBinding("Modifier", "")
.InsertPartBinding("Button", originalModifierPath);
sigAction.RemoveBindingOverride(InputBinding.MaskByGroup(controlSchemeName));
sigAction.ChangeCompositeBinding("OneModifier")
.WithGroup(controlSchemeName)
.Erase();
startIndex = sigAction.GetBindingIndex(controlSchemeName);
}
}
}
// Code that is never reached due to error, but needs separately debugging
}
}
The problem is, at Line 35, I get the following error message:
ArgumentNullException: Value cannot be null.
Parameter name: actionNameOrId
The stack trace message tells me the error is on this line. However, I know sigAction
is not null because the Debug statement before it prints out “OneModifier” (even though the corresponding composite is called “Hold + Button” in the Editor), and that means the argument isn’t null either. Entering “Hold + Button” in the argument gets me the same error. Can anyone tell me what the issue is? Thank you.