- Home /
Can an InputAction have binding and compositeBinding at the same time ?
Hello,
I'm trying to understand the new Input System. In my case, I want to be able to select characters by left clicking them. If i have a character selected and I press on a different one, only the new character will be selected. But if I want to select more than one character, I just have to press "Shift" and the character will be added to the group.
To do this, I thought I could use only one InputAction with a simple binding and a compositeBinding. So if in my performed event, i just have to check if "Shift" was pressed.
It is possible or I have to create two differents Input actions ?
_selectAction = new InputAction(
type: InputActionType.Button,
binding: "<Mouse>/leftButton",
interactions: "press(pressPoint=0.01)"
);
_selectAction.AddCompositeBinding("ButtonWithOneModifier")
.With("Modifier", "<Keyboard>/leftShift")
.With("Button", "<Mouse>/leftButton");
_selectAction.performed += context => OnLeftClick(context);
_selectAction.Enable();
private void OnLeftClick(InputAction.CallbackContext context)
{
//Here you check if the Modifier was pressed, is it possible ?
}
Your answer
Follow this Question
Related Questions
Organizing Unity Input System Code? 0 Answers
Input System - Filtering by Control Type or Scheme 1 Answer
How to consume input when automatically switching control schemes through a Player Input Component 0 Answers
How to mimic Unity's Components based System 1 Answer
,How Do get Touch input to work with the Player Input Component 1 Answer