Struct InputActionProperty
A serializable property type that can either reference an action externally defined in an InputActionAsset or define a new action directly on the property.
Inherited Members
Namespace: UnityEngine.InputSystem
Assembly: Unity.InputSystem.dll
Syntax
[Serializable]
public struct InputActionProperty : IEquatable<InputActionProperty>, IEquatable<InputAction>, IEquatable<InputActionReference>
Remarks
This struct is meant to be used for serialized fields in MonoBehaviour
and
ScriptableObject
classes. It has a custom property drawer attached to it
that allows to switch between using the property as a reference and using it
to define an action in place.
public class MyBehavior : MonoBehaviour
{
// This can be edited in the inspector to either reference an existing
// action or to define an action directly on the component.
public InputActionProperty myAction;
}
Constructors
InputActionProperty(InputAction)
Initialize the property to contain the given action.
Declaration
public InputActionProperty(InputAction action)
Parameters
Type | Name | Description |
---|---|---|
InputAction | action | An action. |
Remarks
When the struct is serialized, it will serialize the given action as part of it.
The reference property will return null
.
See Also
InputActionProperty(InputActionReference)
Initialize the property to use the given action reference.
Declaration
public InputActionProperty(InputActionReference reference)
Parameters
Type | Name | Description |
---|---|---|
InputActionReference | reference | Reference to an InputAction. |
Remarks
When the struct is serialized, it will only serialize a reference to
the given reference
object.
See Also
Properties
action
The effective action held on to by the property.
Declaration
public InputAction action { get; }
Property Value
Type | Description |
---|---|
InputAction | The effective action object contained in the property. |
Remarks
This property will return null
if the property is using a reference and
the referenced action cannot be found. Also, it will be null
if the property
has been manually initialized with a null
InputAction using
InputActionProperty(InputAction).
See Also
reference
If the property is set to use a reference to the action, this property returns
the reference. Otherwise it returns null
.
Declaration
public InputActionReference reference { get; }
Property Value
Type | Description |
---|---|
InputActionReference | Reference to external input action, if defined. |
See Also
Methods
Equals(object)
Check whether the given object is an InputActionProperty referencing the same action.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | An object or |
Returns
Type | Description |
---|---|
bool | True if the given |
Overrides
See Also
Equals(InputAction)
Check whether the property refers to the same action.
Declaration
public bool Equals(InputAction other)
Parameters
Type | Name | Description |
---|---|---|
InputAction | other | An action. |
Returns
Type | Description |
---|---|
bool | True if action is the same as |
See Also
Equals(InputActionProperty)
Compare two action properties to see whether they refer to the same action.
Declaration
public bool Equals(InputActionProperty other)
Parameters
Type | Name | Description |
---|---|---|
InputActionProperty | other | Another action property. |
Returns
Type | Description |
---|---|
bool | True if both properties refer to the same action. |
See Also
Equals(InputActionReference)
Check whether the property references the same action.
Declaration
public bool Equals(InputActionReference other)
Parameters
Type | Name | Description |
---|---|---|
InputActionReference | other | An action reference. |
Returns
Type | Description |
---|---|
bool | True if the property and |
See Also
GetHashCode()
Compute a hash code for the object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code. |
Overrides
See Also
Operators
operator ==(InputActionProperty, InputActionProperty)
Compare the two properties for equivalence.
Declaration
public static bool operator ==(InputActionProperty left, InputActionProperty right)
Parameters
Type | Name | Description |
---|---|---|
InputActionProperty | left | The first property. |
InputActionProperty | right | The second property. |
Returns
Type | Description |
---|---|
bool | True if the two action properties are equivalent. |
See Also
operator !=(InputActionProperty, InputActionProperty)
Compare the two properties for not being equivalent.
Declaration
public static bool operator !=(InputActionProperty left, InputActionProperty right)
Parameters
Type | Name | Description |
---|---|---|
InputActionProperty | left | The first property. |
InputActionProperty | right | The second property. |
Returns
Type | Description |
---|---|
bool | True if the two action properties are not equivalent. |