docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ExecuteEvents

    Sends EventSystem events to the handlers implemented by a GameObject and its ancestors.

    Inheritance
    object
    ExecuteEvents
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.EventSystems
    Assembly: UnityEngine.UI.dll
    Syntax
    public static class ExecuteEvents
    Remarks

    Each event interface in the EventSystems namespace has a matching EventFunction property on this class, such as EventSystems.ExecuteEvents.pointerDownHandler for EventSystems.IPointerDownHandler. Pass one of these properties to Execute or ExecuteHierarchy to invoke that event on a target GameObject.

    Properties

    beginDragHandler

    The event function that sends a begin drag event to an EventSystems.IBeginDragHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IBeginDragHandler> beginDragHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IBeginDragHandler>

    cancelHandler

    The event function that sends a cancel event to an EventSystems.ICancelHandler.

    Declaration
    public static ExecuteEvents.EventFunction<ICancelHandler> cancelHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<ICancelHandler>

    deselectHandler

    The event function that sends a deselection event to an EventSystems.IDeselectHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IDeselectHandler> deselectHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IDeselectHandler>

    dragHandler

    The event function that sends a drag event to an EventSystems.IDragHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IDragHandler> dragHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IDragHandler>

    dropHandler

    The event function that sends a drop event to an EventSystems.IDropHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IDropHandler> dropHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IDropHandler>

    endDragHandler

    The event function that sends an end drag event to an EventSystems.IEndDragHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IEndDragHandler> endDragHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IEndDragHandler>

    initializePotentialDrag

    The event function that sends an initialize potential drag event to an EventSystems.IInitializePotentialDragHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IInitializePotentialDragHandler> initializePotentialDrag { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IInitializePotentialDragHandler>

    moveHandler

    The event function that sends a move event to an EventSystems.IMoveHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IMoveHandler> moveHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IMoveHandler>

    pointerClickHandler

    The event function that sends a pointer click event to an EventSystems.IPointerClickHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerClickHandler> pointerClickHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerClickHandler>

    pointerDownHandler

    The event function that sends a pointer press event to an EventSystems.IPointerDownHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerDownHandler> pointerDownHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerDownHandler>

    pointerEnterHandler

    The event function that sends a pointer enter event to an EventSystems.IPointerEnterHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerEnterHandler> pointerEnterHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerEnterHandler>

    pointerExitHandler

    The event function that sends a pointer exit event to an EventSystems.IPointerExitHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerExitHandler> pointerExitHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerExitHandler>

    pointerMoveHandler

    The event function that sends a pointer move event to an EventSystems.IPointerMoveHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerMoveHandler> pointerMoveHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerMoveHandler>

    pointerUpHandler

    The event function that sends a pointer release event to an EventSystems.IPointerUpHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IPointerUpHandler> pointerUpHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IPointerUpHandler>

    scrollHandler

    The event function that sends a scroll event to an EventSystems.IScrollHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IScrollHandler> scrollHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IScrollHandler>

    selectHandler

    The event function that sends a selection event to an EventSystems.ISelectHandler.

    Declaration
    public static ExecuteEvents.EventFunction<ISelectHandler> selectHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<ISelectHandler>

    submitHandler

    The event function that sends a submit event to an EventSystems.ISubmitHandler.

    Declaration
    public static ExecuteEvents.EventFunction<ISubmitHandler> submitHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<ISubmitHandler>

    updateSelectedHandler

    The event function that sends an update event to the selected EventSystems.IUpdateSelectedHandler.

    Declaration
    public static ExecuteEvents.EventFunction<IUpdateSelectedHandler> updateSelectedHandler { get; }
    Property Value
    Type Description
    ExecuteEvents.EventFunction<IUpdateSelectedHandler>

    Methods

    CanHandleEvent<T>(GameObject)

    Whether the specified game object will be able to handle the specified event.

    Declaration
    public static bool CanHandleEvent<T>(GameObject go) where T : IEventSystemHandler
    Parameters
    Type Name Description
    GameObject go

    The GameObject to check.

    Returns
    Type Description
    bool

    True if the GameObject is active, has at least one enabled handler of type T.

    Type Parameters
    Name Description
    T

    The handler interface to look for.

    ExecuteHierarchy<T>(GameObject, BaseEventData, EventFunction<T>)

    Executes the specified event on the first GameObject in the hierarchy that can handle it.

    Declaration
    public static GameObject ExecuteHierarchy<T>(GameObject root, BaseEventData eventData, ExecuteEvents.EventFunction<T> callbackFunction) where T : IEventSystemHandler
    Parameters
    Type Name Description
    GameObject root

    The GameObject to start the search from.

    BaseEventData eventData

    The event data to pass to each handler.

    ExecuteEvents.EventFunction<T> callbackFunction

    The event function that invokes the event on a handler.

    Returns
    Type Description
    GameObject

    The GameObject that received the event, or null if no GameObject in the hierarchy can handle it.

    Type Parameters
    Name Description
    T

    The handler interface that the event is sent to.

    Remarks

    The search starts at root and walks up through its parents until it reaches a GameObject with a handler of type T. Only that GameObject receives the event.

    Execute<T>(GameObject, BaseEventData, EventFunction<T>)

    Executes the specified event on every handler of type T attached to a GameObject.

    Declaration
    public static bool Execute<T>(GameObject target, BaseEventData eventData, ExecuteEvents.EventFunction<T> functor) where T : IEventSystemHandler
    Parameters
    Type Name Description
    GameObject target

    The GameObject to send the event to.

    BaseEventData eventData

    The event data to pass to each handler.

    ExecuteEvents.EventFunction<T> functor

    The event function that invokes the event on a handler.

    Returns
    Type Description
    bool

    True if the GameObject has at least one handler of type T.

    Type Parameters
    Name Description
    T

    The handler interface that the event is sent to.

    Remarks

    Handlers on disabled components and inactive GameObjects don't receive the event. If a handler throws an exception, the exception is logged and the remaining handlers still receive the event.

    GetEventHandler<T>(GameObject)

    Bubble the specified event on the game object, figuring out which object will actually receive the event.

    Declaration
    public static GameObject GetEventHandler<T>(GameObject root) where T : IEventSystemHandler
    Parameters
    Type Name Description
    GameObject root

    The GameObject to start the search from.

    Returns
    Type Description
    GameObject

    The first active GameObject in the hierarchy that has an enabled handler of type T, or null if there is none.

    Type Parameters
    Name Description
    T

    The handler interface to look for.

    ValidateEventData<T>(BaseEventData)

    Casts a BaseEventData to the type that an event handler expects.

    Declaration
    public static T ValidateEventData<T>(BaseEventData data) where T : class
    Parameters
    Type Name Description
    BaseEventData data

    The BaseEventData to cast.

    Returns
    Type Description
    T

    The event data, cast to T.

    Type Parameters
    Name Description
    T

    The event data type that the handler expects.

    In This Article
    Back to top
    Copyright © 2026 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)