Class MyPlayerControls
Example generated wrapper class for an .inputactions asset, as produced by Unity's Input Action Code Generator when "Generate C# Class" is enabled.
Implements
Namespace: DocCodeSamples.Tests
Assembly: Unity.InputSystem.DocCodeSamples.dll
Syntax
public class MyPlayerControls : IInputActionCollection2, IInputActionCollection, IEnumerable<InputAction>, IEnumerable, IDisposable
Constructors
MyPlayerControls()
Constructs the action asset and looks up its maps and actions.
Declaration
public MyPlayerControls()
Properties
asset
The underlying InputActionAsset wrapped by this class.
Declaration
public InputActionAsset asset { get; }
Property Value
| Type | Description |
|---|---|
| InputActionAsset |
bindingMask
The binding mask applied to the underlying action asset.
Declaration
public InputBinding? bindingMask { get; set; }
Property Value
| Type | Description |
|---|---|
| InputBinding? |
bindings
All bindings in the asset.
Declaration
public IEnumerable<InputBinding> bindings { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<InputBinding> |
controlSchemes
The control schemes defined on the underlying action asset.
Declaration
public ReadOnlyArray<InputControlScheme> controlSchemes { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyArray<InputControlScheme> |
devices
The devices the underlying action asset is restricted to, if any.
Declaration
public ReadOnlyArray<InputDevice>? devices { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyArray<InputDevice>? |
gameplay
Accessor for the actions in the "gameplay" action map.
Declaration
public MyPlayerControls.GameplayActions gameplay { get; }
Property Value
| Type | Description |
|---|---|
| MyPlayerControls.GameplayActions |
Methods
Contains(InputAction)
Checks whether action belongs to this asset.
Declaration
public bool Contains(InputAction action)
Parameters
| Type | Name | Description |
|---|---|---|
| InputAction | action | Action to check. |
Returns
| Type | Description |
|---|---|
| bool | True if the action belongs to this asset. |
Disable()
Disables all action maps in the asset.
Declaration
public void Disable()
Dispose()
Destroys the underlying action asset.
Declaration
public void Dispose()
Enable()
Enables all action maps in the asset.
Declaration
public void Enable()
FindAction(string, bool)
Finds an action by name or ID.
Declaration
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionNameOrId | Name or ID of the action to find. |
| bool | throwIfNotFound | If true, throws instead of returning null when not found. |
Returns
| Type | Description |
|---|---|
| InputAction | The found action, or null if not found and |
FindBinding(InputBinding, out InputAction)
Finds a binding that matches bindingMask.
Declaration
public int FindBinding(InputBinding bindingMask, out InputAction action)
Parameters
| Type | Name | Description |
|---|---|---|
| InputBinding | bindingMask | Mask to match bindings against. |
| InputAction | action | The action the found binding belongs to. |
Returns
| Type | Description |
|---|---|
| int | The index of the found binding, or -1 if not found. |
GetEnumerator()
Returns an enumerator over all actions in the asset.
Declaration
public IEnumerator<InputAction> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<InputAction> | An enumerator over all actions in the asset. |