Description
The Name
property of the InputAction
class represents the identifier for a specific input action. This name is utilized by the input system to detect when the action is triggered, such as when a key is pressed, released, or held down. The name must conform to a specific pattern, allowing only alphanumeric characters, underscores, and hyphens.
Usage
To use the Name
property, assign a string that matches the regular expression pattern ^[a-zA-Z0-9_\-]+$
. This ensures that the name is valid and can be recognized by the input system. The name is then used in conjunction with input methods like Input.Down
, Input.Pressed
, and Input.Released
to check the state of the input action.
Example
// Example of setting the Name property for an InputAction
InputAction jumpAction = new InputAction();
jumpAction.Name = "Jump"; // Valid name
// Using the Name property in input detection
if (Input.Pressed(jumpAction.Name))
{
// Execute jump logic
}