-
Notifications
You must be signed in to change notification settings - Fork 335
DOCS: How to use processors #2171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 38 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
55f2803
restructure processors documentation
ritamerkl 8472341
added scenarios for each processor
ritamerkl 1bfff7b
uniforming scenarios & explanation and adding more details
ritamerkl db25dc2
added pictures and code
ritamerkl 5e9ee17
refined scenarios and added pictures
ritamerkl d37dcd5
added example for clamp processor with picture
ritamerkl c824127
replaced image for clamp processor
ritamerkl 32317b2
corrected grammar and spelling
ritamerkl c365673
Merge branch 'develop' into docs-processors
ritamerkl 1218ba0
fixed formatting
ritamerkl bbea9d6
Merge branch 'docs-processors' of https://github.com/Unity-Technologi…
ritamerkl 3bc0a6e
updated file references to processors
ritamerkl 58a726e
fixed docs link
ritamerkl bc03750
Fixed Doc link
ritamerkl 0c8f1db
Update Packages/com.unity.inputsystem/Documentation~/HowToApplyProces…
ritamerkl 518e2dc
Update Packages/com.unity.inputsystem/Documentation~/ProcessorTypes.md
ritamerkl cda1e1d
Update Packages/com.unity.inputsystem/Documentation~/ProcessorTypes.md
ritamerkl bda4aba
Update Packages/com.unity.inputsystem/Documentation~/HowToApplyProces…
ritamerkl 80d8410
Update Packages/com.unity.inputsystem/Documentation~/HowToApplyProces…
ritamerkl 31b1c1e
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 4b22e08
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 45e2105
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl c1b6852
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 9dab870
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl f25ebc5
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl d2e51b1
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 06a2074
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 185ddae
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 67be9c1
Update Packages/com.unity.inputsystem/Documentation~/ActionBindings.md
ritamerkl f50c2e6
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl deee7ff
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl bfa2d22
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 75fb0e0
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 72361ec
remove TOC for autogenerated TOC
ritamerkl 8f5bf2c
fixed alt text for normalize example
ritamerkl 834e2c4
fixed clamp picture alt text
ritamerkl 8988c27
reworked alt text for images
ritamerkl 9393fbc
Merge branch 'develop' into docs-processors
ritamerkl 801884f
added formatting to Notes
ritamerkl 542f977
Apply suggestions from code review
ritamerkl 58d212b
fixed note comment
ritamerkl c90e7fb
Merge branch 'docs-processors' of https://github.com/Unity-Technologi…
ritamerkl cf18c91
change to active language
ritamerkl 3e09334
fix formatting
ritamerkl 9a47d3b
Merge branch 'develop' into docs-processors
ritamerkl 6614285
Adapt review suggestions
ritamerkl 644fb2e
Merge branch 'develop' into docs-processors
ritamerkl 0bc5fb1
Update Packages/com.unity.inputsystem/Documentation~/ActionBindings.md
ritamerkl 9cf8111
Update Packages/com.unity.inputsystem/Documentation~/ProcessorTypes.md
ritamerkl ffc478b
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 10210b4
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl 52f2dba
Update Packages/com.unity.inputsystem/Documentation~/UsingProcessors.md
ritamerkl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Packages/com.unity.inputsystem/Documentation~/HowToApplyProcessors.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| --- | ||
| uid: input-system-processors | ||
| --- | ||
| # Apply Processors | ||
|
|
||
| The following are the three different ways of applying Processors to input events. For more information on the general usage of Processors, refer to [Using Processors](UsingProcessors.md). | ||
|
|
||
| * [Processors on Bindings](#processors-on-bindings) | ||
| * [Processors on Actions](#processors-on-actions) | ||
| * [Processors on Controls](#processors-on-controls) | ||
|
|
||
| ## Processors on Bindings | ||
|
|
||
| When you create Bindings for your [actions](Actions.md), you can choose to add Processors to the Bindings. These process the values from the controls they bind to, before the system applies them to the Action value. For instance, you might want to invert the `Vector2` values from the controls along the Y axis before passing these values to the Action that drives the input logic for your application. To do this, you can add an [Invert Vector2](ProcessorTypes.md#invert-vector-2) Processor to your Binding. | ||
|
ritamerkl marked this conversation as resolved.
Outdated
|
||
|
|
||
| If you're using Actions defined in the [Input Actions Editor](ActionsEditor.md), or in an [Action Asset](ActionAssets.md), you can add any Processor to your Bindings in the Input Action editor: | ||
|
|
||
| 1. Select the Binding you want to add Processors to so that the right pane of the window displays the properties for that Binding. | ||
| 2. Select the **Add (+)** icon on the __Processors__ foldout to open a list of all available Processors that match your control type. | ||
| 3. Choose a Processor type to add a Processor instance of that type. The Processor now appears under the __Processors__ foldout. | ||
| 4. (Optional) If the Processor has any parameters, you can edit them in the __Processors__ foldout. | ||
|
|
||
|  | ||
|
|
||
| To remove a Processor, click the Remove (-) icon next to it. You can also use the up and down arrows to change the order of Processors. This affects the order in which the system processes values. | ||
|
|
||
| If you create your Bindings in code, you can add Processors like this: | ||
|
|
||
| ```CSharp | ||
| var action = new InputAction(); | ||
| action.AddBinding("<Gamepad>/leftStick") | ||
| .WithProcessor("invertVector2(invertX=false)"); | ||
| ``` | ||
|
|
||
| ## Processors on Actions | ||
|
|
||
| Processors on Actions work in the same way as Processors on Bindings, but they affect all controls bound to an Action, rather than just the controls from a specific Binding. If there are Processors on both the Binding and the Action, the system processes the ones from the Binding first. | ||
|
|
||
| You can add and edit Processors on Actions in the [Input Actions Editor](ActionsEditor.md), or in an [Action Asset](ActionAssets.md) the [same way](#processors-on-bindings) as you would for Bindings: select an Action to edit, then add one or more Processors in the right window pane. | ||
|
|
||
| If you create your Actions in code, you can add Processors like this: | ||
|
|
||
| ```CSharp | ||
| var action = new InputAction(processors: "invertVector2(invertX=false)"); | ||
| ``` | ||
|
|
||
| ## Processors on Controls | ||
|
|
||
| You can have any number of Processors directly on an [`InputControl`](../api/UnityEngine.InputSystem.InputControl.html), which then process the values read from the Control. Whenever you call [`ReadValue`](../api/UnityEngine.InputSystem.InputControl-1.html#UnityEngine_InputSystem_InputControl_1_ReadValue) on a Control, all Processors on that Control process the value before it gets returned to you. You can use [`ReadUnprocessedValue`](../api/UnityEngine.InputSystem.InputControl-1.html#UnityEngine_InputSystem_InputControl_1_ReadUnprocessedValue) on a Control to bypass the Processors. | ||
|
|
||
| The Input System adds Processors to a Control during device creation, if they're specified in the Control's [layout](Layouts.md). You can't add Processors to existing Controls after they've been created, so you can only add Processors to Controls when you're [creating custom devices](Devices.md#creating-custom-devices). The devices that the Input System supports out of the box already have some useful Processors added on their Controls. For instance, sticks on gamepads have a [Stick Deadzone](ProcessorTypes.md#stick-deadzone) Processor. | ||
|
|
||
| If you're using a layout generated by the Input System from a [state struct](Devices.md#step-1-the-state-struct) using [`InputControlAttributes`](../api/UnityEngine.InputSystem.Layouts.InputControlAttribute.html), you can specify the Processors you want to use via the [`processors`](../api/UnityEngine.InputSystem.Layouts.InputControlAttribute.html#UnityEngine_InputSystem_Layouts_InputControlAttribute_processors) property of the attribute, like this: | ||
|
|
||
| ```CSharp | ||
| public struct MyDeviceState : IInputStateTypeInfo | ||
| { | ||
| public FourCC format => return new FourCC('M', 'Y', 'D', 'V'); | ||
|
|
||
| // Add an axis deadzone to the Control to ignore values | ||
| // smaller then 0.2, as our Control does not have a stable | ||
| // resting position. | ||
| [InputControl(layout = "Axis", processors = "AxisDeadzone(min=0.2)")] | ||
| public short axis; | ||
| } | ||
| ``` | ||
|
|
||
| If you [create a layout from JSON](Layouts.md#layout-from-json), you can specify Processors on your Controls like this: | ||
|
|
||
| ```CSharp | ||
| { | ||
| "name" : "MyDevice", | ||
| "extend" : "Gamepad", // Or some other thing | ||
| "controls" : [ | ||
| { | ||
| "name" : "axis", | ||
| "layout" : "Axis", | ||
| "offset" : 4, | ||
| "format" : "FLT", | ||
| "processors" : "AxisDeadzone(min=0.2)" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
Binary file added
BIN
+86 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Clamp-Editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+141 KB
...ages/com.unity.inputsystem/Documentation~/Images/Processors-Deadzone-Editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+72.4 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Invert-Editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+913 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Normalize-Fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+913 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Normalize-Slow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+103 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-NormalizeAsset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+111 KB
...s/com.unity.inputsystem/Documentation~/Images/Processors-Scale-Look-Pointer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+115 KB
...ges/com.unity.inputsystem/Documentation~/Images/Processors-Scale-Look-Stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+83.7 KB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Scale-Look.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.39 MB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Ship-Left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.4 MB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Ship-Neutral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.4 MB
Packages/com.unity.inputsystem/Documentation~/Images/Processors-Ship-Right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.