docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BaseInputModule

    A base module that raises events and sends them to GameObjects.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    BaseInputModule
    PointerInputModule
    Inherited Members
    UIBehaviour.Awake()
    UIBehaviour.Start()
    UIBehaviour.OnDestroy()
    UIBehaviour.IsActive()
    UIBehaviour.OnValidate()
    UIBehaviour.Reset()
    UIBehaviour.OnRectTransformDimensionsChange()
    UIBehaviour.OnBeforeTransformParentChanged()
    UIBehaviour.OnTransformParentChanged()
    UIBehaviour.OnDidApplyAnimationProperties()
    UIBehaviour.OnCanvasGroupChanged()
    UIBehaviour.OnCanvasHierarchyChanged()
    UIBehaviour.IsDestroyed()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.transformHandle
    Component.gameObject
    Component.tag
    Object.GetEntityId()
    Object.MemberwiseClone()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    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.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectsByType(Type)
    Object.FindObjectsByType(Type, FindObjectsInactive)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsByType<T>()
    Object.FindObjectsByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.EventSystems
    Assembly: UnityEngine.UI.dll
    Syntax
    [RequireComponent(typeof(EventSystem))]
    public abstract class BaseInputModule : UIBehaviour
    Remarks

    An Input Module is a component of the EventSystem that is responsible for raising events and sending them to GameObjects for handling. The BaseInputModule is a class that all Input Modules in the EventSystem inherit from. Examples of provided modules are TouchInputModule and StandaloneInputModule, if these are inadequate for your project you can create your own by extending from the BaseInputModule.

    Examples
    using UnityEngine;
    using UnityEngine.EventSystems;
    
    /**
     * Create a module that every tick sends a 'Move' event to
     * the target object
     */
    public class MyInputModule : BaseInputModule
    {
        public GameObject m_TargetObject;
    
        public override void Process()
        {
            if (m_TargetObject == null)
                return;
            ExecuteEvents.Execute (m_TargetObject, new BaseEventData (eventSystem), ExecuteEvents.moveHandler);
        }
    }

    Fields

    m_InputOverride

    The BaseInput that replaces the default one, if any.

    Declaration
    protected BaseInput m_InputOverride
    Field Value
    Type Description
    BaseInput

    m_RaycastResultCache

    The reusable list that raycast results are collected into.

    Declaration
    [NonSerialized]
    protected List<RaycastResult> m_RaycastResultCache
    Field Value
    Type Description
    List<RaycastResult>

    Properties

    eventSystem

    The EventSystem that this input module belongs to.

    Declaration
    protected EventSystem eventSystem { get; }
    Property Value
    Type Description
    EventSystem

    input

    The current BaseInput being used by the input module.

    Declaration
    public BaseInput input { get; }
    Property Value
    Type Description
    BaseInput

    inputOverride

    Used to override the default BaseInput for the input module.

    Declaration
    public BaseInput inputOverride { get; set; }
    Property Value
    Type Description
    BaseInput
    Remarks

    With this it is possible to bypass the Input system with your own but still use the same InputModule. For example this can be used to feed fake input into the UI or interface with a different input system.

    sendPointerHoverToParent

    True if pointer hover events will be sent to the parent

    Declaration
    protected bool sendPointerHoverToParent { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ActivateModule()

    Called when the module is activated. Override this if you want custom code to execute when you activate your module.

    Declaration
    public virtual void ActivateModule()

    ConvertPointerEventScrollDeltaToTicks(Vector2)

    Converts PointerEventData.scrollDelta to corresponding number of ticks of the scroll wheel.

    Declaration
    public virtual Vector2 ConvertPointerEventScrollDeltaToTicks(Vector2 scrollDelta)
    Parameters
    Type Name Description
    Vector2 scrollDelta

    The scroll delta to convert.

    Returns
    Type Description
    Vector2

    The number of scroll wheel ticks that the scroll delta corresponds to.

    Remarks

    Input Module implementations are free to apply a scaling factor to their PointerEventData's scrollDelta. This method can be used when a system needs to treat scaling-independent input values.

    ConvertUIToolkitPointerId(PointerEventData)

    Returns Id of the pointer following PointerId convention.

    Declaration
    public virtual int ConvertUIToolkitPointerId(PointerEventData sourcePointerData)
    Parameters
    Type Name Description
    PointerEventData sourcePointerData

    PointerEventData whose pointerId will be converted to UI Toolkit pointer convention.

    Returns
    Type Description
    int

    The equivalent UI Toolkit pointer ID, or -1 if the UI Toolkit isn't available.

    See Also
    IPointerEvent

    DeactivateModule()

    Called when the module is deactivated. Override this if you want custom code to execute when you deactivate your module.

    Declaration
    public virtual void DeactivateModule()

    DetermineMoveDirection(float, float)

    Given an input movement, determine the best MoveDirection.

    Declaration
    protected static MoveDirection DetermineMoveDirection(float x, float y)
    Parameters
    Type Name Description
    float x

    X movement.

    float y

    Y movement.

    Returns
    Type Description
    MoveDirection

    The move direction that best matches the movement, or MoveDirection.None if the movement is inside the dead zone.

    DetermineMoveDirection(float, float, float)

    Given an input movement, determine the best MoveDirection.

    Declaration
    protected static MoveDirection DetermineMoveDirection(float x, float y, float deadZone)
    Parameters
    Type Name Description
    float x

    X movement.

    float y

    Y movement.

    float deadZone

    Dead zone.

    Returns
    Type Description
    MoveDirection

    The move direction that best matches the movement, or MoveDirection.None if the movement is inside the dead zone.

    FindCommonRoot(GameObject, GameObject)

    Finds and returns a common root GameObject for two given GameObject instances.

    Declaration
    protected static GameObject FindCommonRoot(GameObject g1, GameObject g2)
    Parameters
    Type Name Description
    GameObject g1

    The first GameObject to use in the search for a common root.

    GameObject g2

    The second GameObject to use in the search for a common root.

    Returns
    Type Description
    GameObject

    The common root GameObject, or null if none found.

    Remarks

    Walks up the transform hierarchy of both objects to find the first common ancestor. Used by the event system to determine exit/enter boundaries when the pointer moves between UI elements that share a common root.

    Examples

    Use this to find a common ancestor of two UI objects for event boundaries. The following gets the common root of a button and a slider under a panel.

    GameObject a = transform.Find("Panel/Button").gameObject;
    GameObject b = transform.Find("Panel/Slider").gameObject;
    GameObject root = FindCommonRoot(a, b); // Returns the Panel's GameObject.
    if (root != null) Debug.Log("Common root: " + root.name);

    FindFirstRaycast(List<RaycastResult>)

    Return the first valid RaycastResult.

    Declaration
    protected static RaycastResult FindFirstRaycast(List<RaycastResult> candidates)
    Parameters
    Type Name Description
    List<RaycastResult> candidates

    The raycast results to search, in priority order.

    Returns
    Type Description
    RaycastResult

    The first result that hit a GameObject, or an empty RaycastResult if there is none.

    GetAxisEventData(float, float, float)

    Given some input data generate an AxisEventData that can be used by the event system.

    Declaration
    protected virtual AxisEventData GetAxisEventData(float x, float y, float moveDeadZone)
    Parameters
    Type Name Description
    float x

    X movement.

    float y

    Y movement.

    float moveDeadZone

    Move dead zone.

    Returns
    Type Description
    AxisEventData

    The reusable axis event data of this module, updated with the given movement.

    GetBaseEventData()

    Generate a BaseEventData that can be used by the EventSystem.

    Declaration
    protected virtual BaseEventData GetBaseEventData()
    Returns
    Type Description
    BaseEventData

    The reusable base event data of this module, reset to its default state.

    GetNavigationEventDeviceType(BaseEventData)

    Returns the type of device that generated this event.

    Declaration
    public virtual NavigationDeviceType GetNavigationEventDeviceType(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    An event generated by this input module.

    Returns
    Type Description
    NavigationDeviceType

    The type of device that generated this event.

    Remarks

    This method is used by UI Toolkit's TextField to allow navigation in and out of the TextField when using a device other than a keyboard.

    If we don't know what the source of the event is, this method should return Unknown. Input Modules with more information on the event source should override this method to reflect that information.

    This method's behavior is undefined for events other than Move, Submit, or Cancel.

    HandlePointerExitAndEnter(PointerEventData, GameObject)

    Sends pointer enter and exit events when moving from the currently entered GameObject to a new one.

    Declaration
    protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget)
    Parameters
    Type Name Description
    PointerEventData currentPointerData

    The pointer event data to send with each event, and to update with the new entered GameObject.

    GameObject newEnterTarget

    The GameObject that the pointer entered, or null if the pointer is over nothing.

    Remarks

    This method walks up the hierarchy until it finds a common root between the currently entered GameObject and the new one. It sends exit events up to (but not including) the common root, and then sends enter events up to (but not including) the common root. It also sends move events before the exit events, after the enter events, and on the hovered GameObjects when the pointer data changed.

    IsModuleSupported()

    Check to see if the module is supported. Override this if you have a platform specific module (eg. TouchInputModule that you do not want to activate on standalone.)

    Declaration
    public virtual bool IsModuleSupported()
    Returns
    Type Description
    bool

    Is the module supported.

    IsPointerOverGameObject(int)

    If the module is pointer based, then override this to return true if the pointer is over an event system object.

    Declaration
    public virtual bool IsPointerOverGameObject(int pointerId)
    Parameters
    Type Name Description
    int pointerId

    The ID of the pointer.

    Returns
    Type Description
    bool

    True if the pointer is over an EventSystem object.

    OnDisable()

    Removes this module from the list of modules of the EventSystem.

    Declaration
    protected override void OnDisable()
    Overrides
    UIBehaviour.OnDisable()

    OnEnable()

    Caches the EventSystem on the same GameObject and adds this module to its list of modules.

    Declaration
    protected override void OnEnable()
    Overrides
    UIBehaviour.OnEnable()

    Process()

    Process the current tick for the module.

    Declaration
    public abstract void Process()

    ShouldActivateModule()

    Should the module be activated.

    Declaration
    public virtual bool ShouldActivateModule()
    Returns
    Type Description
    bool

    True if the EventSystem can make this module the current one.

    UpdateModule()

    Update the internal state of the Module.

    Declaration
    public virtual void UpdateModule()
    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)