docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class PlayerInput.ActionEvent

    An event associated with an PlayerInput action.

    Inheritance
    object
    UnityEventBase
    UnityEvent<InputAction.CallbackContext>
    PlayerInput.ActionEvent
    Implements
    ISerializationCallbackReceiver
    Inherited Members
    UnityEvent<InputAction.CallbackContext>.AddListener(UnityAction<InputAction.CallbackContext>)
    UnityEvent<InputAction.CallbackContext>.RemoveListener(UnityAction<InputAction.CallbackContext>)
    UnityEvent<InputAction.CallbackContext>.FindMethod_Impl(string, Type)
    UnityEvent<InputAction.CallbackContext>.Invoke(InputAction.CallbackContext)
    UnityEventBase.FindMethod_Impl(string, object)
    UnityEventBase.GetPersistentEventCount()
    UnityEventBase.GetPersistentTarget(int)
    UnityEventBase.GetPersistentMethodName(int)
    UnityEventBase.SetPersistentListenerState(int, UnityEventCallState)
    UnityEventBase.GetPersistentListenerState(int)
    UnityEventBase.AddListener(object, MethodInfo)
    UnityEventBase.RemoveListener(object, MethodInfo)
    UnityEventBase.RemoveAllListeners()
    UnityEventBase.Invoke(object[])
    UnityEventBase.ToString()
    UnityEventBase.GetValidMethodInfo(object, string, Type[])
    UnityEventBase.GetValidMethodInfo(Type, string, Type[])
    UnityEventBase.ValidateRegistration(MethodInfo, object, PersistentListenerMode)
    UnityEventBase.ValidateRegistration(MethodInfo, object, PersistentListenerMode, Type)
    UnityEventBase.RegisterPersistentListener(int, object, MethodInfo)
    UnityEventBase.RegisterPersistentListener(int, object, Type, MethodInfo)
    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    [Serializable]
    public class PlayerInput.ActionEvent : UnityEvent<InputAction.CallbackContext>, ISerializationCallbackReceiver
    Remarks

    Represents an event invoked in response to actions being triggered.

    Contains the ID and name of the InputAction being triggered and the associated UnityAction to handle the action response.

    The list of action events is specified in PlayerInput Editor UI based on the selected InputActionAsset. The individual action callbacks are then specified in a MonoBehaviour.

    Examples
    public class MyPlayerScript : MonoBehaviour
    {
        void OnFireEvent(InputAction.CallbackContext context)
        {
            // Handle fire event
        }
    }

    Constructors

    ActionEvent()

    Construct an empty action event.

    Declaration
    public ActionEvent()
    Remarks

    The event will not have an associated action.

    See Also
    actionEvents

    ActionEvent(Guid, string)

    Construct an action event and associated it with an action by GUID.

    Declaration
    public ActionEvent(Guid actionGUID, string name = null)
    Parameters
    Type Name Description
    Guid actionGUID

    Action GUID.

    string name

    Name of the action.

    Remarks

    The event will be associated with the specified action.

    See Also
    actionEvents

    ActionEvent(InputAction)

    Construct an action event and associate it with an action.

    Declaration
    public ActionEvent(InputAction action)
    Parameters
    Type Name Description
    InputAction action

    The action to associate with the event. The action must be part of an action asset.

    Remarks

    The event will be associated with the specified action. The action must be part of an action asset.

    Exceptions
    Type Condition
    ArgumentNullException

    The action is null.

    ArgumentException

    The action is not part of an action asset.

    See Also
    actionEvents

    Properties

    actionId

    Action GUID string for the action that triggered the event.

    Declaration
    public string actionId { get; }
    Property Value
    Type Description
    string
    See Also
    actionEvents
    InputAction.CallbackContext

    actionName

    Name of the action that triggered the event.

    Declaration
    public string actionName { get; }
    Property Value
    Type Description
    string
    See Also
    actionEvents
    InputAction.CallbackContext

    Implements

    ISerializationCallbackReceiver

    See Also

    actionEvents
    InputAction.CallbackContext
    In This Article
    Back to top
    Copyright © 2025 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)