Skip to content

Commit 3eacb2a

Browse files
committed
Still working on 2253
1 parent b66365a commit 3eacb2a

7 files changed

Lines changed: 86 additions & 65 deletions

File tree

Packages/com.unity.inputsystem/Documentation~/Actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The association between an Action and the device controls which perform that inp
1111

1212
To use actions in your code, you must use the [Input Actions editor](actions-editor.md) to configure the mapping between the Action and one or more device controls. For example in this screenshot, the "Move" action is displayed, showing its bindings the left gamepad stick, and the keyboard's arrow keys.
1313

14-
![Actions Bindings](Images/ActionsBinding.png)<br/>
14+
![The Actions panel of the Input Actions Editor in Project Settings](Images/ActionsBinding.png)<br/>
1515
*The Actions panel of the Input Actions Editor in Project Settings*
1616

1717
You can then get a reference to this action in your code, and check its value, or attach a callback method to be notified when it is performed. See the [Actions Workflow page](using-actions-workflow.md) for a simple example script demonstrating this.

Packages/com.unity.inputsystem/Documentation~/composite-bindings.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ uid: input-system-composite-bindings
44

55
# Composite Bindings
66

7-
Sometimes, you might want to have several Controls act in unison to mimic a different type of Control. The most common example of this is using the W, A, S, and D keys on the keyboard to form a 2D vector Control equivalent to mouse deltas or gamepad sticks. Another example is to use two keys to form a 1D axis equivalent to a mouse scroll axis.
7+
You might want to have several controls act in unison to mimic a different type of control. The most common example of this is using the W, A, S, and D keys on the keyboard to form a 2D vector control equivalent to mouse deltas or gamepad sticks. Another example is to use two keys to form a 1D axis equivalent to a mouse scroll axis.
88

9-
Composite Bindings, made up of multiple **sub-bindings** solve this problem. Composites themselves don't bind directly to Controls; instead, they take values from their **sub-bindings** that do, and then synthesize input from those values together into a single virtual control binding.
9+
This is difficult to implement with normal bindings. You can bind a [`ButtonControl`](xref:UnityEngine.InputSystem.Controls.ButtonControl) to an action expecting a `Vector2`, but doing so results in an exception at runtime when the Input System tries to read a `Vector2` from a control that can deliver only a `float`.
10+
11+
Composite bindings (that is, bindings that are made up of other bindings) solve this problem. Composites themselves don't bind directly to controls; instead, they source values from other bindings that do, and then synthesize input on the fly from those values.
1012

1113
To create a composite binding, select the appropriate [composite type](binding-types.md) for your action while [adding a binding in the actions editor](./add-duplicate-delete-binding.md). The types of composite bindings available are as follows:
1214

Packages/com.unity.inputsystem/Documentation~/configure-bindings-from-code.md

Lines changed: 52 additions & 49 deletions
Large diffs are not rendered by default.

Packages/com.unity.inputsystem/Documentation~/create-project-wide-actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The asset is created in your project, and automatically assigned as the **projec
2222

2323
The Action Asset appears in your Project view, and is named "InputSystem_Actions". This is where your new configuration of actions is saved, including any changes you make to it.
2424

25-
![](images/InputSystemActionsAsset.png)<br/>
25+
![The new Actions Asset in your Project window](images/InputSystemActionsAsset.png)<br/>
2626
*The new Actions Asset in your Project window*
2727

2828
When you create an action asset this way, the new asset contains a set of default actions that are useful in many common scenarios. You can [configure them](./configure-actions.md) or [add new actions](./create-edit-delete-actions.md) to suit your project.
2929

30-
![image alt text](./Images/ProjectSettingsInputActionsSimpleShot.png)
30+
![The Input System Package Project Settings after creating and assigning the default actions](./Images/ProjectSettingsInputActionsSimpleShot.png)
3131
*The Input System Package Project Settings after creating and assigning the default actions*
3232

3333
Once you have created and assigned project-wide actions, the Input System Package page in Project Settings displays the **Actions Editor** interface. Read more about how to use the [Actions Editor](actions-editor.md) to configure your actions.

Packages/com.unity.inputsystem/Documentation~/default-actions.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ These default actions mean that in many cases, you can start scripting with the
1515

1616
### The legacy default Actions Asset
1717

18-
The Input System Package also comes with an asset called `DefaultInputActions.inputactions` containing a default set of Actions. This default actions asset is older than, and entirely separate from the default project-wide actions described above.
19-
20-
This is a legacy asset that remains included in the package for backward compatibility only, and not recommended for use in new projects. It should not be confused with the default project-wide actions described above.
21-
18+
> [!NOTE]
19+
> The default actions asset is entirely separate from the [default project-wide actions](xref:project-wide-actions). It is a legacy asset that is included in the package for backwards compatibility.
20+
21+
The Input System package provides an asset called `DefaultInputActions.inputactions` which you can reference directly in your projects like any other Unity asset. The asset is also available in code form through the [`DefaultInputActions`](xref:UnityEngine.InputSystem.DefaultInputActions) class.
22+
23+
24+
```CSharp
25+
void Start()
26+
{
27+
// Create an instance of the default actions.
28+
var actions = new DefaultInputActions();
29+
actions.Player.Look.performed += OnLook;
30+
actions.Player.Move.performed += OnMove;
31+
actions.Enable();
32+
}
33+
```

Packages/com.unity.inputsystem/Documentation~/generate-cs-api-from-actions.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ Once applied, the Input System creates a C# script containing API that matches t
2828
using UnityEngine;
2929
using UnityEngine.InputSystem;
3030

31-
// IGameplayActions is an interface generated from the "gameplay" action map.
32-
// Your interface name will match the name you chose for your action map.
31+
// IGameplayActions is an interface generated from the newly added "gameplay"
32+
// action map, triggered by the "Generate Interfaces" checkbox. Note that if
33+
// you change the default values for the action map, the name of the interface
34+
// will be different.
35+
3336
public class MyPlayerScript : MonoBehaviour, IGameplayActions
3437
{
3538
// MyPlayerControls is the C# class that Unity generated.
@@ -42,8 +45,8 @@ public class MyPlayerScript : MonoBehaviour, IGameplayActions
4245
if (controls == null)
4346
{
4447
controls = new MyPlayerControls();
45-
// Tell the "gameplay" action map that we want to get told about
46-
// when actions get triggered.
48+
// Tell the "gameplay" action map that we want to be
49+
// notified when actions get triggered.
4750
controls.gameplay.SetCallbacks(this);
4851
}
4952
controls.gameplay.Enable();
@@ -68,4 +71,4 @@ public class MyPlayerScript : MonoBehaviour, IGameplayActions
6871
```
6972

7073
> [!NOTE]
71-
> To regenerate the .cs file, right-click the .inputactions asset in the Project Browser and choose "Reimport".
74+
> To regenerate the .cs file, right-click the .inputactions asset in the Project Browser and select **Reimpor**.

Packages/com.unity.inputsystem/Documentation~/introduction-to-bindings.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ uid: input-system-bindings-intro
66

77
![A flowchart showing the general workflow of the Input System, with icons representing the different concepts. It starts with the User icon, which then leads into the Input Device and its Controls icon. This then leads into the Action Map and Actions concept. The Input Device and Action Map and Actions icons are collectively grouped under the Binding header. This leads into the final icon representing your action code.](Images/ConceptsOverview.png)
88

9-
A **binding** represents a connection between an [Action](actions.md) and one or more [Controls](controls.md) identified by a [Control path](./control-paths.md). For example, the right trigger of a gamepad (a control) might be bound to an an action named `accelerate`, so that pulling the right trigger causes a car to accelerate in your game.
9+
A **binding** represents a connection between an [Action](actions.md) and one or more [Controls](controls.md) identified by a [Control path](./control-paths.md). For example, the right trigger of a gamepad (a control) might be bound to an an action named "accelerate", so that pulling the right trigger causes a car to accelerate in your game.
1010

11-
You can add multiple bindings to an action, which is generally useful for supporting multiple types of input device. For example, in the default set of actions, the "Move" action has a binding to the left gamepad stick and the WSAD keys, which means input through any of these bindings will perform the action.
11+
You can add multiple bindings to an action, which is generally useful for supporting multiple types of input device. For example, in the default set of actions, the "Move" action has a binding to the left gamepad stick and the WASD keys, which means input through any of these bindings will perform the action.
1212

1313
You can also bind multiple controls from the same device to an action. For example, both the left and right trigger of a gamepad could be mapped to the same action, so that pulling either trigger has the same result in your game.
1414

1515
![The default "move" action with its multiple bindings highlighted](./Images/ActionWithMultipleBindings.png)<br/>
1616
_The default "Move" action in the Actions Editor window, displaying the multiple bindings associated with it._
1717

18+
You can also set up [Composite](composite-bindings) bindings, which don't bind to the controls themselves, but receive their input from **Part Bindings** and then return a value representing a composition of those inputs. For example, the right trigger on the gamepad can act as a strength multiplier on the value of the left stick.

0 commit comments

Comments
 (0)