Class PressInteraction
Performs the action at specific points in a button press-and-release sequence according top behavior.
Namespace: UnityEngine.InputSystem.Interactions
Syntax
[Preserve]
public class PressInteraction : IInputInteraction
Remarks
By default, uses PressOnly which performs the action as soon as the control crosses the button press threshold defined by pressPoint. The action then will not trigger again until the control is first released.
Can be set to instead trigger on release (i.e. when the control goes back below the button press threshold) using ReleaseOnly or can be set to trigger on both press and release using PressAndRelease).
Note that using an explicit press interaction is only necessary if the goal is to either customize the press behavior of a button or when binding to controls that are not buttons as such (the press interaction compares magnitudes to pressPoint and thus any type of control that can deliver a magnitude can act as a button). The default behavior available out of the box when binding Button type actions to button-type controls (ButtonControl) corresponds to using a press modifier with behavior set to PressOnly and pressPoint left at default.
Fields
behavior
Determines how button presses trigger the action.
Declaration
[Tooltip("Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and release.")]
public PressBehavior behavior
Field Value
Type | Description |
---|---|
PressBehavior |
Remarks
By default (PressOnly), the action is performed on press. With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and on release.
pressPoint
Amount of actuation required before a control is considered pressed.
Declaration
[Tooltip("The amount of actuation a control requires before being considered pressed. If not set, default to 'Default Press Point' in the global input settings.")]
public float pressPoint
Field Value
Type | Description |
---|---|
Single |
Remarks
If zero (default), defaults to defaultButtonPressPoint.
Methods
Process(ref InputInteractionContext)
Declaration
public void Process(ref InputInteractionContext context)
Parameters
Type | Name | Description |
---|---|---|
InputInteractionContext | context |
Implements
Reset()
Declaration
public void Reset()