docs.unity.cn

Input System 1.6.1

    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.

    Inherited Members
    ValueType.ToString()
    Namespace: UnityEngine.InputSystem
    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.

    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.

    Properties

    action

    The action held on to by the property.

    Declaration
    public readonly InputAction action { get; }
    Property Value
    Type Description
    InputAction

    The 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).

    reference

    If the property contains a reference to the action, this property returns the reference. Otherwise it returns null.

    Declaration
    public readonly InputActionReference reference { get; }
    Property Value
    Type Description
    InputActionReference

    Reference to external input action, if defined.

    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
    Boolean

    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
    Boolean

    True if action is the same as other.

    Implements
    IEquatable<T>.Equals(T)

    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
    Boolean

    True if both properties refer to the same action.

    Implements
    IEquatable<T>.Equals(T)

    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
    Boolean

    True if the property and other reference the same action.

    Implements
    IEquatable<T>.Equals(T)

    GetHashCode()

    Compute a hash code for the object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A hash code.

    Overrides
    ValueType.GetHashCode()

    Operators

    Equality(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
    Boolean

    True if the two action properties are equivalent.

    See Also
    Equals(InputActionProperty)

    Inequality(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
    Boolean

    True if the two action properties are not equivalent.

    See Also
    Equals(InputActionProperty)

    See Also

    InputAction
    InputActionReference
    In This Article
    • Constructors
      • InputActionProperty(InputAction)
      • InputActionProperty(InputActionReference)
    • Properties
      • action
      • reference
    • Methods
      • Equals(Object)
      • Equals(InputAction)
      • Equals(InputActionProperty)
      • Equals(InputActionReference)
      • GetHashCode()
    • Operators
      • Equality(InputActionProperty, InputActionProperty)
      • Inequality(InputActionProperty, InputActionProperty)
    • See Also
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Saturday, May 27, 2023