Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions Packages/com.unity.inputsystem/Documentation~/Interactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,12 @@ uid: input-system-interactions
---
# Interactions

- [Operation](#operation)
- [Multiple Controls on an Action](#multiple-controls-on-an-action)
- [Multiple Interactions on a Binding](#multiple-interactions-on-a-binding)
- [Timeouts](#timeouts)
- [Using Interactions](#using-interactions)
- [Interactions applied to Bindings](#interactions-applied-to-bindings)
- [Interactions applied to Actions](#interactions-applied-to-actions)
- [Predefined Interactions](#predefined-interactions)
- [Default Interaction](#default-interaction)
- [Press](#press)
- [Hold](#hold)
- [Tap](#tap)
- [SlowTap](#slowtap)
- [MultiTap](#multitap)
- [Writing custom Interactions](#writing-custom-interactions)

An Interaction represents a specific input pattern. For example, a [hold](#hold) is an Interaction that requires a Control to be held for at least a minimum amount of time.

Interactions drive responses on Actions. You can place them on individual Bindings or an Action as a whole, in which case they apply to every Binding on the Action. At runtime, when a particular interaction completes, this triggers the Action.

![Interaction Properties](Images/InteractionProperties.png)


Use Interactions to interpret specific input patterns from Controls that define Action behavior.

|Topic|Description|
|-----|-----------|
|[Introduction to interactions](introduction-interactions.md)| Use Interactions on Bindings and Actions to read control input patterns and trigger Actions.|
|[Apply interactions to Bindings](apply-interactions-bindings.md)| Apply Interactions to individual Bindings.|
|[Apply Interactions to Actions](apply-interactions-actions.md)| Apply Interactions to Actions, and all the Bindings associated with that Action. |
|[Predefined interactions](predefined-interactions.md)| Use the Input System's default and built-in Interactions on your Actions and Bindings.|
|[Write custom interactions](write-custom-interactions.md)| Write your own custom Interactions for your Actions and Bindings.|
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
* [Input Action Assets](ActionAssets.md)
* [Input Bindings](ActionBindings.md)
* [Interactions](Interactions.md)
* [Introduction to interactions](introduction-interactions.md)
* [Apply interactions to Bindings](apply-interactions-bindings.md)
* [Apply Interactions to Actions](apply-interactions-actions.md)
* [Predefined interactions](predefined-interactions.md)
* [Default Interactions](default-interactions.md)
* [Built-in Interactions](built-in-interactions.md)
* [Write custom interactions](write-custom-interactions.md)
* [Devices](Devices.md)
* [Controls](Controls.md)
* [Processors](Processors.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Apply Interactions to Actions

Applying Interactions directly to an Action is equivalent to applying them to all Bindings for the Action. You can use this instead of manually adding the same Interaction(s) to multiple Bindings.

To apply Interactions to individual Bindings, refer to [Apply Interactions to Bindings](apply-interactions-bindings.md).

If you apply Interactions to both an Action and its Bindings, then the effect is the same as if the Action's Interactions are on the list of Interactions on each of the Bindings. This means that the Input System applies the Binding's Interactions first, and then the Action's Interactions.

## Apply Interactions to Actions via the Editor

To apply interactions via the Input Action Editor:

1. Select an Action to edit, so that the right pane of the window displays the properties for that Action.
1. Select the plus icon on the __Interactions__ foldout to open a list of all available Interactions types.
1. Select an Interaction type to add an Interaction instance of that type. The Interaction now appears in the __Interactions__ foldout.
1. If the Interaction has any parameters, you can now edit them at this stage.

## Apply Interactions to Actions via code

If you create your Actions in code, you can add Interactions like this:

```CSharp
var Action = new InputAction(Interactions: "tap(duration=0.8)");
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Apply Interactions to Bindings

When you create Bindings for your [Actions](actions.md), you can choose to add Interactions to the Bindings via the Editor, or via code.

To apply Interactions to all Bindings on an Action, refer to [Apply Interactions to Actions](apply-interactions-actions.md).

## Apply Interactions to Bindings via the Editor

If you're using [project-wide actions](ActionsEditor.md), or [Input Action Assets](ActionAssets.md), you can add any Interaction to your Bindings via the Input Action editor.

1. Once you have [created some Bindings](ActionsEditor.md#bindings), select the Binding you want to add Interactions to, so that the right pane of the window displays the properties for that Binding.
1. Select the plus icon on the __Interactions__ foldout to open a list of all available Interactions types.
1. Select an Interaction type to add an Interaction instance of that type. The Interaction now appears in the __Interactions__ foldout.
1. If the Interaction has any parameters, you can now edit them at this stage.

![Binding Processors](Images/BindingProcessors.png)

To remove an Interaction, select the minus (-) button next to it. To change the [order of Interactions](introduction-interactions.md#multiple-interactions-on-a-binding), select the up and down arrows.

## Apply Interactions to Bindings via code

To add Interactions to Bindings that you created in code, you can use the following code sample as a template:

```CSharp
var Action = new InputAction();
action.AddBinding("<Gamepad>/leftStick")
.WithInteractions("tap(duration=0.8)");
```
Loading