docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class InputSystemUIInputModule

    Input module that takes its input from input actions.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    BaseInputModule
    InputSystemUIInputModule
    Inherited Members
    BaseInputModule.m_RaycastResultCache
    BaseInputModule.m_InputOverride
    BaseInputModule.FindFirstRaycast(List<RaycastResult>)
    BaseInputModule.DetermineMoveDirection(float, float)
    BaseInputModule.DetermineMoveDirection(float, float, float)
    BaseInputModule.FindCommonRoot(GameObject, GameObject)
    BaseInputModule.HandlePointerExitAndEnter(PointerEventData, GameObject)
    BaseInputModule.GetAxisEventData(float, float, float)
    BaseInputModule.GetBaseEventData()
    BaseInputModule.ShouldActivateModule()
    BaseInputModule.DeactivateModule()
    BaseInputModule.UpdateModule()
    BaseInputModule.IsModuleSupported()
    BaseInputModule.input
    BaseInputModule.inputOverride
    BaseInputModule.eventSystem
    UIBehaviour.Start()
    UIBehaviour.IsActive()
    UIBehaviour.OnValidate()
    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.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    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.CompareTag(string)
    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.gameObject
    Component.tag
    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.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    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.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
    Namespace: UnityEngine.InputSystem.UI
    Assembly: Unity.InputSystem.dll
    Syntax
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/manual/UISupport.html#setting-up-ui-input")]
    public class InputSystemUIInputModule : BaseInputModule
    Remarks

    This module processes all UI input based on the Input System. It is the "glue" between UI systems (UGUI, UITK) and the Input System.

    When adding this component from code (such as through GameObject.AddComponent), the resulting module will automatically have DefaultInputActions assigned to it. If you want to use your own actions, you should create an InputActionAsset with the necessary UI actions. You can copy the default actions and edit them as you need. To have editable Input Actions out-of-the box you can use the project-wide actions through InputSystem.actions. More information about this can be read in the manual documentation.

    This module can be configured in the Editor > Inspector when added as a component to a GameObject.

    This UI input module has the advantage over other such modules that it doesn't have to know what devices and types of devices input is coming from. Instead, the actions hide the actual sources of input from the module.

    Examples
    using UnityEngine;
    using UnityEngine.InputSystem;
    using UnityEngine.InputSystem.UI;
    using UnityEngine.EventSystems;
    
    class InputSystemUIInputModuleExample : MonoBehaviour
    {
        private InputSystemUIInputModule uiModule;
    
        // Configure the InputSystemUIInputModule component programmatically on Start()
        // But a lot of this could be done at runtime as well.
        void Start()
        {
            // Find the EventSystem in the scene
            var eventSystem = EventSystem.current;
    
            // Get the InputSystemUIInputModule component
            uiModule = eventSystem.GetComponent<InputSystemUIInputModule>();
    
            // Using the default input actions just as an example. Another InputActionAsset can be used.
            DefaultInputActions defaultInputActions = new DefaultInputActions();
            // Example on how to assign individual actions programmatically
            uiModule.actionsAsset = defaultInputActions.asset;
            uiModule.leftClick = InputActionReference.Create(defaultInputActions.UI.Click);
            uiModule.scrollWheel = InputActionReference.Create(defaultInputActions.UI.ScrollWheel);
    
            // Set other fields programmatically
            uiModule.deselectOnBackgroundClick = true;
            uiModule.pointerBehavior = UIPointerBehavior.SingleMouseOrPenButMultiTouchAndTrack;
            uiModule.cursorLockBehavior = InputSystemUIInputModule.CursorLockBehavior.ScreenCenter;
        }
    
        // Example on how programmatically set the move repeat delay based on the move repeat rate
        void SetMoveRepeat(float value)
        {
            uiModule.moveRepeatRate = value;
            uiModule.moveRepeatDelay = value * (1.2f);
        }
    }

    Properties

    actionsAsset

    The InputActionAsset that contains the necessary UI actions used by the UI module.

    Declaration
    public InputActionAsset actionsAsset { get; set; }
    Property Value
    Type Description
    InputActionAsset
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    cancel

    An InputAction delivering a float button value that determines when ICancelHandler is triggered.

    Declaration
    public InputActionReference cancel { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    The events generated from this input will be received by UnityEngine.EventSystems.ICancelHandler.

    This action together with move and submit form the sources for navigation-style UI input.

    This action should have its type set to Button.

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("move");
    var submitAction = map.AddAction("submit");
    var cancelAction = map.AddAction("cancel");
    

    moveAction.AddBinding("<Gamepad>/*stick"); moveAction.AddBinding("<Gamepad>/dpad"); submitAction.AddBinding("<Gamepad>/buttonSouth"); cancelAction.AddBinding("<Gamepad>/buttonEast");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).move = InputActionReference.Create(moveAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).submit = InputActionReference.Create(submitAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).cancelAction = InputActionReference.Create(cancelAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    cursorLockBehavior

    Where to position the pointer when the cursor is locked.

    Declaration
    public InputSystemUIInputModule.CursorLockBehavior cursorLockBehavior { get; set; }
    Property Value
    Type Description
    InputSystemUIInputModule.CursorLockBehavior
    Remarks

    By default, the pointer is positioned at -1, -1 in screen space when the cursor is locked. This has implications for using ray casters like UnityEngine.EventSystems.PhysicsRaycaster because the raycasts will be sent from the pointer position. By setting the value of cursorLockBehavior to ScreenCenter, the raycasts will be sent from the center of the screen. This is useful when trying to interact with world space UI using the UnityEngine.EventSystems.IPointerEnterHandler and UnityEngine.EventSystems.IPointerExitHandler interfaces when the cursor is locked.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    deselectOnBackgroundClick

    Whether to clear the current selection when a click happens that does not hit any GameObject.

    Declaration
    public bool deselectOnBackgroundClick { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    If true (default), clicking outside of any GameObject will reset the current selection By toggling this behavior off, background clicks will keep the current selection. I.e. EventSystem.currentSelectedGameObject will not be changed.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    leftClick

    An InputAction delivering a float button value that determines whether the left button of a pointer is pressed.

    Declaration
    public InputActionReference leftClick { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    Clicks on this button will use UnityEngine.EventSystems.PointerEventData.InputButton.Left for UnityEngine.EventSystems.PointerEventData.button.

    Together with point, rightClick, middleClick, and scrollWheel, this forms the basis for pointer-type UI input.

    Note that together with point, this action is necessary for a pointer to be functional. The other clicks and scrollWheel are optional, however.

    This action should have its type set to PassThrough and its expectedControlType set to "Button".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("scroll");
    var clickAction = map.AddAction("click");
    

    pointAction.AddBinding("<Mouse>/position"); pointAction.AddBinding("<Touchscreen>/touch*/position");

    clickAction.AddBinding("<Mouse>/leftButton"); clickAction.AddBinding("<Touchscreen>/touch*/press");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).point = InputActionReference.Create(pointAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).leftClick = InputActionReference.Create(clickAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    middleClick

    An InputAction delivering a float button value that determines whether the middle button of a pointer is pressed.

    Declaration
    public InputActionReference middleClick { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    Clicks on this button will use UnityEngine.EventSystems.PointerEventData.InputButton.Middle for UnityEngine.EventSystems.PointerEventData.button.

    Together with leftClick, rightClick, scrollWheel, and point, this forms the basis for pointer-type UI input.

    Note that the action is optional. A pointer is fully functional with just point and leftClick alone.

    This action should have its type set to PassThrough and its expectedControlType set to "Button".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("scroll");
    var leftClickAction = map.AddAction("leftClick");
    var middleClickAction = map.AddAction("middleClick");
    

    pointAction.AddBinding("<Mouse>/position"); pointAction.AddBinding("<Touchscreen>/touch*/position");

    leftClickAction.AddBinding("<Mouse>/leftButton"); leftClickAction.AddBinding("<Touchscreen>/touch*/press");

    middleClickAction.AddBinding("<Mouse>/middleButton");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).point = InputActionReference.Create(pointAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).leftClick = InputActionReference.Create(leftClickAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).middleClick = InputActionReference.Create(middleClickAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    move

    An InputAction delivering a Vector2 2D motion vector used for sending UnityEngine.EventSystems.AxisEventData navigation events.

    Declaration
    public InputActionReference move { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    The events generated from this input will be received by UnityEngine.EventSystems.IMoveHandler.OnMove(UnityEngine.EventSystems.AxisEventData).

    This action together with submit and cancel form the sources for navigation-style UI input.

    This action should have its type set to PassThrough and its expectedControlType set to "Vector2".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("move");
    var submitAction = map.AddAction("submit");
    var cancelAction = map.AddAction("cancel");
    

    moveAction.AddBinding("<Gamepad>/*stick"); moveAction.AddBinding("<Gamepad>/dpad"); submitAction.AddBinding("<Gamepad>/buttonSouth"); cancelAction.AddBinding("<Gamepad>/buttonEast");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).move = InputActionReference.Create(moveAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).submit = InputActionReference.Create(submitAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).cancelAction = InputActionReference.Create(cancelAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    moveRepeatDelay

    Delay in seconds between an initial move action and a repeated move action while move is actuated.

    Declaration
    public float moveRepeatDelay { get; set; }
    Property Value
    Type Description
    float
    Remarks

    While move is being held down, the input module will first wait for moveRepeatDelay seconds after the first actuation of move and then trigger a move event every moveRepeatRate seconds.

    See Also
    moveRepeatRate
    AxisEventData

    moveRepeatRate

    Delay in seconds between repeated move actions while move is actuated.

    Declaration
    public float moveRepeatRate { get; set; }
    Property Value
    Type Description
    float
    Remarks

    While move is being held down, the input module will first wait for moveRepeatDelay seconds after the first actuation of move and then trigger a move event every moveRepeatRate seconds.

    Note that a maximum of one UnityEngine.EventSystems.AxisEventData will be sent per frame. This means that even if multiple time increments of the repeat delay have passed since the last update, only one move repeat event will be generated.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    point

    An InputAction delivering a Vector2 2D screen position used as a cursor for pointing at UI elements.

    Declaration
    public InputActionReference point { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    The values read from this action determine UnityEngine.EventSystems.PointerEventData.position and UnityEngine.EventSystems.PointerEventData.delta.

    Together with leftClick, rightClick, middleClick, and scrollWheel, this forms the basis for pointer-type UI input.

    This action should have its type set to PassThrough and its expectedControlType set to "Vector2".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("Point");
    

    pointAction.AddBinding("<Mouse>/position"); pointAction.AddBinding("<Touchscreen>/touch*/position");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).point = InputActionReference.Create(pointAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    pointerBehavior

    How to deal with the presence of pointer-type input from multiple devices.

    Declaration
    public UIPointerBehavior pointerBehavior { get; set; }
    Property Value
    Type Description
    UIPointerBehavior
    Remarks

    By default, this is set to SingleMouseOrPenButMultiTouchAndTrack which will treat input from Mouse and Pen devices as coming from a single on-screen pointer but will treat input from devices such as XRController and Touchscreen as their own discrete pointers.

    The primary effect of this setting is to determine whether the user can concurrently point at more than a single UI element or not. Whenever multiple pointers are allowed, more than one element may have a pointer over it at any one point and thus several elements can be interacted with concurrently.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    rightClick

    An InputAction delivering a float" button value that determines whether the right button of a pointer is pressed.

    Declaration
    public InputActionReference rightClick { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    Clicks on this button will use UnityEngine.EventSystems.PointerEventData.InputButton.Right for UnityEngine.EventSystems.PointerEventData.button.

    Together with leftClick, middleClick, scrollWheel, and point, this forms the basis for pointer-type UI input.

    Note that the action is optional. A pointer is fully functional with just point and leftClick alone.

    This action should have its type set to PassThrough and its expectedControlType set to "Button".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("scroll");
    var leftClickAction = map.AddAction("leftClick");
    var rightClickAction = map.AddAction("rightClick");
    

    pointAction.AddBinding("<Mouse>/position"); pointAction.AddBinding("<Touchscreen>/touch*/position");

    leftClickAction.AddBinding("<Mouse>/leftButton"); leftClickAction.AddBinding("<Touchscreen>/touch*/press");

    rightClickAction.AddBinding("<Mouse>/rightButton");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).point = InputActionReference.Create(pointAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).leftClick = InputActionReference.Create(leftClickAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).rightClick = InputActionReference.Create(rightClickAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    scrollDeltaPerTick

    A multiplier value that allows you to adjust the scroll wheel speed sent to uGUI (Unity UI) components.

    Declaration
    public float scrollDeltaPerTick { get; set; }
    Property Value
    Type Description
    float
    Remarks

    This value controls the magnitude of the PointerEventData.scrollDelta value, when the scroll wheel is rotated one tick. It acts as a multiplier, so a value of 1 passes through the original value and behaves the same as the legacy Standalone Input Module.

    A value larger than one increases the scrolling speed per tick, and a value less than one decreases the speed.

    You can set this to a negative value to invert the scroll direction. A value of zero prevents mousewheel scrolling from working at all.

    Note: this has no effect on UI Toolkit content, only uGUI components.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    scrollWheel

    An InputAction delivering a Vector2 scroll wheel value used for sending UnityEngine.EventSystems.PointerEventData events.

    Declaration
    public InputActionReference scrollWheel { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    The values read from this action determine UnityEngine.EventSystems.PointerEventData.scrollDelta.

    Together with leftClick, rightClick, middleClick, and point, this forms the basis for pointer-type UI input.

    Note that the action is optional. A pointer is fully functional with just point and leftClick alone.

    This action should have its type set to PassThrough and its expectedControlType set to "Vector2".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("scroll");
    var scrollAction = map.AddAction("scroll");
    

    pointAction.AddBinding("<Mouse>/position"); pointAction.AddBinding("<Touchscreen>/touch*/position");

    scrollAction.AddBinding("<Mouse>/scroll");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).point = InputActionReference.Create(pointAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).scrollWheel = InputActionReference.Create(scrollAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    submit

    An InputAction delivering a float button value that determines when ISubmitHandler is triggered.

    Declaration
    public InputActionReference submit { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    The events generated from this input will be received by UnityEngine.EventSystems.ISubmitHandler.

    This action together with move and cancel form the sources for navigation-style UI input.

    This action should have its type set to Button.

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var pointAction = map.AddAction("move");
    var submitAction = map.AddAction("submit");
    var cancelAction = map.AddAction("cancel");
    

    moveAction.AddBinding("<Gamepad>/*stick"); moveAction.AddBinding("<Gamepad>/dpad"); submitAction.AddBinding("<Gamepad>/buttonSouth"); cancelAction.AddBinding("<Gamepad>/buttonEast");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).move = InputActionReference.Create(moveAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).submit = InputActionReference.Create(submitAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).cancelAction = InputActionReference.Create(cancelAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    trackedDeviceDragThresholdMultiplier

    Scales the drag threshold of EventSystem for tracked devices to make selection easier.

    Declaration
    public float trackedDeviceDragThresholdMultiplier { get; set; }
    Property Value
    Type Description
    float
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    trackedDeviceOrientation

    An InputAction delivering a Quaternion value reflecting the orientation of TrackedDevices. In combination with trackedDevicePosition, this is used to determine the transform of tracked devices from which to raycast into the UI scene.

    Declaration
    public InputActionReference trackedDeviceOrientation { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    trackedDeviceOrientation and trackedDevicePosition together replace point for UI input from TrackedDevice. Other than that, UI input for tracked devices is no different from "normal" pointer-type input. This means that leftClick, rightClick, middleClick, and scrollWheel can all be used for tracked device input like for regular pointer input.

    This action should have its type set to PassThrough and its expectedControlType set to "Quaternion".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var positionAction = map.AddAction("position");
    var orientationAction = map.AddAction("orientation");
    var clickAction = map.AddAction("click");
    

    positionAction.AddBinding("<TrackedDevice>/devicePosition"); orientationAction.AddBinding("<TrackedDevice>/deviceRotation"); clickAction.AddBinding("<TrackedDevice>/trigger");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).trackedDevicePosition = InputActionReference.Create(positionAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).trackedDeviceOrientation = InputActionReference.Create(orientationAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).leftClick = InputActionReference.Create(clickAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    trackedDevicePosition

    An InputAction delivering a Vector3 value reflecting the position of TrackedDevices. In combination with trackedDeviceOrientation, this is used to determine the transform of tracked devices from which to raycast into the UI scene.

    Declaration
    public InputActionReference trackedDevicePosition { get; set; }
    Property Value
    Type Description
    InputActionReference
    Remarks

    trackedDeviceOrientation and trackedDevicePosition together replace point for UI input from TrackedDevice. Other than that, UI input for tracked devices is no different from "normal" pointer-type input. This means that leftClick, rightClick, middleClick, and scrollWheel can all be used for tracked device input like for regular pointer input.

    This action should have its type set to PassThrough and its expectedControlType set to "Vector3".

    var asset = ScriptableObject.Create<InputActionAsset>();
    var map = asset.AddActionMap("UI");
    var positionAction = map.AddAction("position");
    var orientationAction = map.AddAction("orientation");
    var clickAction = map.AddAction("click");
    

    positionAction.AddBinding("<TrackedDevice>/devicePosition"); orientationAction.AddBinding("<TrackedDevice>/deviceRotation"); clickAction.AddBinding("<TrackedDevice>/trigger");

    ((InputSystemUIInputModule)EventSystem.current.currentInputModule).trackedDevicePosition = InputActionReference.Create(positionAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).trackedDeviceOrientation = InputActionReference.Create(orientationAction); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).leftClick = InputActionReference.Create(clickAction);

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    xrTrackingOrigin

    A Transform representing the real world origin for tracking devices.

    Declaration
    public Transform xrTrackingOrigin { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    This is used to convert real world positions and rotations for all Tracked pointers into Unity's global space. When using the XR Interaction Toolkit, this should be pointing to the XR Rig's Transform. If unset, or set to null, the Unity world origin will be used as the basis for all tracked positions and rotations.

    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    Methods

    ActivateModule()

    Called by EventSystem when the input module is made current.

    Declaration
    public override void ActivateModule()
    Overrides
    UnityEngine.EventSystems.BaseInputModule.ActivateModule()
    Remarks

    There's no need to call this method directly unless for specific reasons. It is called by EventSystem when the input module is made current. It sets UnityEngine.EventSystems.EventSystem.currentSelectedGameObject to UnityEngine.EventSystems.EventSystem.firstSelectedGameObject if nothing is selected.

    Examples
    using UnityEngine;
    using UnityEngine.EventSystems;
    using UnityEngine.InputSystem.UI;
    
    public class ActivateModuleExample : MonoBehaviour
    {
        private InputSystemUIInputModule uiModule;
        void Start()
        {
            // Find the EventSystem in the scene
            var eventSystem = EventSystem.current;
    
            // Get the InputSystemUIInputModule component
            uiModule = eventSystem.GetComponent<InputSystemUIInputModule>();
    
            // Manually activate the module
            uiModule.ActivateModule();
        }
    }
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    AssignDefaultActions()

    Assigns default input actions asset and input actions, similar to how defaults are assigned when creating UI module in editor. Useful for creating InputSystemUIInputModule at runtime.

    Declaration
    public void AssignDefaultActions()
    Remarks

    This instantiates DefaultInputActions and assigns it to actionsAsset. It also assigns all the various individual actions such as point and leftClick.

    Note that if an InputSystemUIInputModule component is programmatically added to a GameObject, it will automatically receive the default actions as part of its OnEnable method. Use UnassignActions() to remove these assignments.

    Examples
    #if UNITY_INPUT_SYSTEM_ENABLE_UI
    
    using UnityEngine;
    using UnityEngine.InputSystem.UI;
    
    namespace DocCodeSamples.Tests
    {
        internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
        {
            // Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
            public InputSystemUIInputModule uiModule;
    
            void Start()
            {
                // Assign default actions
                AssignActions();
            }
    
            void AssignActions()
            {
                if (uiModule != null)
                    uiModule.AssignDefaultActions();
                else
                    Debug.LogError("InputSystemUIInputModule not found.");
            }
    
            void UnassignActions()
            {
                if (uiModule != null)
                    uiModule.UnassignActions();
                else
                    Debug.LogError("InputSystemUIInputModule not found.");
            }
    
            void OnDestroy()
            {
                // Unassign actions when the object is destroyed
                UnassignActions();
            }
        }
    }
    #endif
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    Awake()

    Declaration
    protected override void Awake()
    Overrides
    UnityEngine.EventSystems.UIBehaviour.Awake()
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    ConvertUIToolkitPointerId(PointerEventData)

    Declaration
    public override int ConvertUIToolkitPointerId(PointerEventData sourcePointerData)
    Parameters
    Type Name Description
    PointerEventData sourcePointerData
    Returns
    Type Description
    int
    Overrides
    UnityEngine.EventSystems.BaseInputModule.ConvertUIToolkitPointerId(UnityEngine.EventSystems.PointerEventData)
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    GetLastRaycastResult(int)

    Returns the most recent raycast information for a given pointer or touch.

    Declaration
    public RaycastResult GetLastRaycastResult(int pointerOrTouchId)
    Parameters
    Type Name Description
    int pointerOrTouchId

    ID of the pointer or touch. Meaning this should correspond to either PointerEventData.pointerId or touchId. The pointer ID generally corresponds to the deviceId of the pointer device. An exception to this are touches as a Touchscreen may have multiple pointers (one for each active finger). For touch, you can use the touchId of the touch.

     Negative values will return an invalid <xref href="UnityEngine.EventSystems.RaycastResult" data-throw-if-not-resolved="false"></xref>.
    
    Returns
    Type Description
    RaycastResult

    The most recent raycast information.

    Remarks

    This method is for the most recent raycast, but depending on when it's called is not guaranteed to be for the current frame. This method can be used to determine raycast distances and hit information for visualization.
    Use UnityEngine.EventSystems.RaycastResult.isValid to determine if pointer hit anything.

    Examples
    using UnityEngine;
    using UnityEngine.EventSystems;
    using UnityEngine.InputSystem;
    using UnityEngine.InputSystem.UI;
    
    public class GetLastRaycastResultExample : MonoBehaviour
    {
        public InputSystemUIInputModule uiModule;
    
        void PrintLastRaycastResult(int pointerId)
        {
            if (uiModule)
            {
                // Retrieve the last raycast result for the given pointer ID
                RaycastResult raycastResult = uiModule.GetLastRaycastResult(pointerId);
    
                // Check if the raycast result is valid
                if (raycastResult.isValid)
                {
                    // Print details about the raycast result
                    Debug.Log($"Pointer ID: {pointerId}");
                    Debug.Log($"Hit GameObject: {raycastResult.gameObject.name}");
                    Debug.Log($"Distance: {raycastResult.distance}");
                    Debug.Log($"World Position: {raycastResult.worldPosition}");
                }
            }
    
        }
    
        void Update()
        {
            PrintLastRaycastResult(Mouse.current.deviceId);
        }
    }
    See Also
    touchId
    deviceId

    IsPointerOverGameObject(int)

    Check whether the given pointer or touch is currently hovering over a GameObject.

    Declaration
    public override bool IsPointerOverGameObject(int pointerOrTouchId)
    Parameters
    Type Name Description
    int pointerOrTouchId

    ID of the pointer or touch. Meaning this should correspond to either PointerEventData.pointerId or touchId. The pointer ID generally corresponds to the deviceId of the pointer device. An exception to this are touches as a Touchscreen may have multiple pointers (one for each active finger). For touch, you can use the touchId of the touch.

     Note that for touch, a pointer will stay valid for one frame before being removed. In other words,
     when <xref href="UnityEngine.InputSystem.TouchPhase.Ended" data-throw-if-not-resolved="false"></xref> or <xref href="UnityEngine.InputSystem.TouchPhase.Canceled" data-throw-if-not-resolved="false"></xref> is received for a touch
     and the touch was over a <code>GameObject</code>, the associated pointer is still considered over that
     object for the frame in which the touch ended.
    
     To check whether any pointer is over a <code>GameObject</code>, simply pass a negative value such as -1.
    
    Returns
    Type Description
    bool

    True if the given pointer is currently hovering over a GameObject.

    Overrides
    BaseInputModule.IsPointerOverGameObject(int)
    Remarks

    The result is true if the given pointer has caused an IPointerEnter event to be sent to a GameObject.

    This method can be invoked via EventSystem.current.IsPointerOverGameObject.

    Be aware that this method relies on state set up during UI event processing that happens in EventSystem.Update, that is, as part of MonoBehaviour updates. This step happens after input processing. Thus, calling this method earlier than that in the frame will make it poll state from last frame.

    Calling this method from within an InputAction callback (such as performed) will result in a warning. See the "UI vs Game Input" sample shipped with the Input System package for how to deal with this fact.

    Examples
    // In general, the pointer ID corresponds to the device ID:
    EventSystem.current.IsPointerOverGameObject(XRController.leftHand.deviceId);
    EventSystem.current.IsPointerOverGameObject(Mouse.current.deviceId);
    
    // For touch input, pass the ID of a touch:
    EventSystem.current.IsPointerOverGameObject(Touchscreen.primaryTouch.touchId.ReadValue());
    
    // But can also pass the ID of the entire Touchscreen in which case the result
    // is true if any touch is over a GameObject:
    EventSystem.current.IsPointerOverGameObject(Touchscreen.current.deviceId);
    
    // Finally, any negative value will be interpreted as "any pointer" and will
    // return true if any one pointer is currently over a GameObject:
    EventSystem.current.IsPointerOverGameObject(-1);
    EventSystem.current.IsPointerOverGameObject(); // Equivalent.
    See Also
    touchId
    deviceId

    OnDestroy()

    Declaration
    protected override void OnDestroy()
    Overrides
    UnityEngine.EventSystems.UIBehaviour.OnDestroy()
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    OnDisable()

    Declaration
    protected override void OnDisable()
    Overrides
    UnityEngine.EventSystems.BaseInputModule.OnDisable()
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    OnEnable()

    Declaration
    protected override void OnEnable()
    Overrides
    UnityEngine.EventSystems.BaseInputModule.OnEnable()
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    Process()

    Declaration
    public override void Process()
    Overrides
    UnityEngine.EventSystems.BaseInputModule.Process()
    Remarks

    This method is automatically called by UnityEngine.EventSystems.EventSystem.Update() once per frame. There is no need to call it manually. Unless for specific use cases.

    It processes all UIPointerType and UIPointerBehavior pointer types, as well as navigation input state from m_PointerStates and m_NavigationState. These fields hold state based on the actions set up for the UI action map of actionsAsset. The InputAction callbacks are responsible for updating their state, which means state can change multiple times during a frame, even though it will only be processed once per frame. For example, in case there are multiple clicks or touches in a single frame, they can allocate multiple pointers in the same frame, which will all then be processed by frame when UnityEngine.EventSystems.EventSystem.Update() calls this method.

    Also, this method is responsible for purging stale pointers when a device is removed, and for filtering pointer states

    Examples
    using UnityEngine;
    using UnityEngine.InputSystem.UI;
    
    public class CustomInputModuleProcessor : MonoBehaviour
    {
        // Reference to the InputSystemUIInputModule, set in the Inspector
        public InputSystemUIInputModule uiModule;
    
        void Update()
        {
            // Process the input module in the Update loop for a specific case
            // if this needs to be called outside the EventSystem.Update() event
            if (uiModule != null)
            {
                uiModule.Process();
            }
        }
    }
    See Also
    UIPointerType
    UIPointerBehavior
    Process()
    actionsAsset

    Reset()

    Declaration
    protected override void Reset()
    Overrides
    UnityEngine.EventSystems.UIBehaviour.Reset()
    See Also
    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()

    UnassignActions()

    Remove all action assignments.

    Declaration
    public void UnassignActions()
    Remarks

    Resets actionsAsset reference as well as all individual actions references, such as leftClick , and removes the correspondent callbacks hooked for performed and canceled

    It also disposes defaultActions.

    If the current actions were enabled by the UI input module, they will be disabled in the process.

    Examples
    #if UNITY_INPUT_SYSTEM_ENABLE_UI
    
    using UnityEngine;
    using UnityEngine.InputSystem.UI;
    
    namespace DocCodeSamples.Tests
    {
        internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
        {
            // Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
            public InputSystemUIInputModule uiModule;
    
            void Start()
            {
                // Assign default actions
                AssignActions();
            }
    
            void AssignActions()
            {
                if (uiModule != null)
                    uiModule.AssignDefaultActions();
                else
                    Debug.LogError("InputSystemUIInputModule not found.");
            }
    
            void UnassignActions()
            {
                if (uiModule != null)
                    uiModule.UnassignActions();
                else
                    Debug.LogError("InputSystemUIInputModule not found.");
            }
    
            void OnDestroy()
            {
                // Unassign actions when the object is destroyed
                UnassignActions();
            }
        }
    }
    #endif
    See Also
    AssignDefaultActions()

    See Also

    BaseInputModule
    InputActionAsset
    InputAction
    EventSystem
    AssignDefaultActions()
    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)