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

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • action
      • asset
    • Methods
      • Create(InputAction)
      • Set(InputAction)
      • Set(InputActionAsset, string, string)
      • ToInputAction()
      • ToString()
    • Operators
      • implicit operator InputAction(InputActionReference)
    • See Also
    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)