Class InputActionReference
References a specific InputAction in an InputActionMap stored inside an InputActionAsset.
Inherited Members
Namespace: UnityEngine.InputSystem
Assembly: Unity.InputSystem.dll
Syntax
public class InputActionReference : ScriptableObject
Remarks
The difference to a plain reference directly to an InputAction object is that an InputActionReference can be serialized without causing the referenced InputAction to be serialized as well. The reference will remain intact even if the action or the map that contains the action is renamed.
References can be set up graphically in the editor by dropping individual actions from the project browser onto a reference field.
Properties
action
The action that the reference resolves to. Null if the action cannot be found.
Declaration
public InputAction action { get; }
Property Value
Type | Description |
---|---|
InputAction | The action that reference points to. |
Remarks
Actions are resolved on demand based on their internally stored IDs.
See Also
asset
The asset that the referenced action is part of. Null if the reference is not initialized or if the asset has been deleted.
Declaration
public InputActionAsset asset { get; }
Property Value
Type | Description |
---|---|
InputActionAsset | InputActionAsset of the referenced action. |
See Also
Methods
Create(InputAction)
Create a new InputActionReference object that references the given action.
Declaration
public static InputActionReference Create(InputAction action)
Parameters
Type | Name | Description |
---|---|---|
InputAction | action | An input action. Must be contained in an InputActionMap
that is itself contained in an InputActionAsset. Can be |
Returns
Type | Description |
---|---|
InputActionReference | A new InputActionReference referencing |
See Also
Set(InputAction)
Initialize the reference to refer to the given action.
Declaration
public void Set(InputAction action)
Parameters
Type | Name | Description |
---|---|---|
InputAction | action | An input action. Must be contained in an InputActionMap
that is itself contained in an InputActionAsset. Can be |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
See Also
Set(InputActionAsset, string, string)
Look up an action in the given asset and initialize the reference to point to it.
Declaration
public void Set(InputActionAsset asset, string mapName, string actionName)
Parameters
Type | Name | Description |
---|---|---|
InputActionAsset | asset | An .inputactions asset. |
string | mapName | Name of the InputActionMap in |
string | actionName | Name of the action in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException | No action map called |
See Also
ToInputAction()
Declaration
public InputAction ToInputAction()
Returns
Type | Description |
---|---|
InputAction |
See Also
ToString()
Return a string representation of the reference useful for debugging.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of the reference. |
Overrides
See Also
Operators
implicit operator InputAction(InputActionReference)
Convert an InputActionReference to the InputAction it points to.
Declaration
public static implicit operator InputAction(InputActionReference reference)
Parameters
Type | Name | Description |
---|---|---|
InputActionReference | reference | An InputActionReference object. Can be null. |
Returns
Type | Description |
---|---|
InputAction | The value of action from |