docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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.

    Implements
    IEquatable<InputActionProperty>
    IEquatable<InputAction>
    IEquatable<InputActionReference>
    Inherited Members
    ValueType.ToString()
    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
    InputAction
    InputActionReference

    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
    InputAction
    InputActionReference

    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
    InputAction
    InputActionReference

    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
    InputAction
    InputActionReference

    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 null.

    Returns
    Type Description
    bool

    True if the given obj is an InputActionProperty equivalent to this one.

    Overrides
    ValueType.Equals(object)
    See Also
    Equals(InputActionProperty)

    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 other.

    See Also
    InputAction
    InputActionReference

    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
    InputAction
    InputActionReference

    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 other reference the same action.

    See Also
    InputAction
    InputActionReference

    GetHashCode()

    Compute a hash code for the object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code.

    Overrides
    ValueType.GetHashCode()
    See Also
    InputAction
    InputActionReference

    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
    Equals(InputActionProperty)

    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.

    See Also
    Equals(InputActionProperty)

    Implements

    IEquatable<T>
    IEquatable<T>
    IEquatable<T>

    See Also

    InputAction
    InputActionReference
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)