docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class InputActionReference

    References a specific InputAction in an InputActionMap stored inside an InputActionAsset.

    Inheritance
    object
    Object
    ScriptableObject
    InputActionReference
    Inherited Members
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType(Type)
    Object.name
    Object.hideFlags
    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
    InputActionProperty
    InputAction
    InputActionAsset

    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
    InputActionProperty
    InputAction
    InputActionAsset

    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 null in which case the reference is reset to its default state which does not reference an action.

    Returns
    Type Description
    InputActionReference

    A new InputActionReference referencing action.

    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    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 null in which case the reference is reset to its default state which does not reference an action.

    Exceptions
    Type Condition
    InvalidOperationException

    action is not contained in an InputActionMap that is itself contained in an InputActionAsset.

    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    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 asset (see actionMaps). Case-insensitive.

    string actionName

    Name of the action in mapName. Case-insensitive.

    Exceptions
    Type Condition
    ArgumentNullException

    asset is null -or- mapName is null or empty -or- actionName is null or empty.

    ArgumentException

    No action map called mapName could be found in asset -or- no action called actionName could be found in the action map called mapName in asset.

    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    ToInputAction()

    Declaration
    public InputAction ToInputAction()
    Returns
    Type Description
    InputAction
    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    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
    Object.ToString()
    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    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 reference. Can be null.

    See Also
    InputActionProperty
    InputAction
    InputActionAsset

    See Also

    InputActionProperty
    InputAction
    InputActionAsset
    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)