UxrControlInput Class

A component derived from EventTrigger that simplifies the handling of events triggered by UI controls. Among the key benefits are:  

  • Be able to write UI code by subscribing to events generated by UI controls. Global static events are also provided to handle events coming from any control.
  • New controls with more complex behaviour can inherit from this class and add their own logic. Event triggers are provided so that handling events can be done by overriding the appropriate methods, making sure the base class is always called at the beginning. An example is UxrToggleControlInput.
  • Each UxrControlInput can specify the audio/haptic feedback for the click/down/up events.

Inheritance Hierarchy

System.Object
  Object
    Component
      Behaviour
        MonoBehaviour
          EventTrigger
            UltimateXR.UI.UnityInputModule.Controls.UxrControlInput
              UltimateXR.UI.UnityInputModule.Controls.UxrToggleControlInput
Namespace: UltimateXR.UI.UnityInputModule.Controls
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

public class UxrControlInput : EventTrigger


The UxrControlInput type exposes the following members.

Constructors

NameDescription
Public methodUxrControlInput

Properties

NameDescription
Public propertyEnabled Gets or sets whether the object can be interacted with and will send any events.
Public propertyFeedbackOnClick Gets or sets the feedback when the UI element was clicked.
Public propertyFeedbackOnDown Gets or sets the feedback when the UI element was pressed.
Public propertyFeedbackOnUp Gets or sets the feedback when the UI element was released.
Public propertyGameObject Gets the control’s GameObject
Public propertyImage Gets the Unity Image component on the same object if it exists.
Public propertyInteractable Gets or sets whether the widget is interactable or not. The widget should have a Selectable component.
Public propertyIsDragging Gets whether the control is currently being dragged.
Public propertyPressAndHoldDuration Gets or sets how many seconds need to pass to trigger a PressHeld event
Public propertyRectTransform Gets the Unity RectTransform component.
Public propertyScrollRect Gets the ScrollRect reference used in drag/scroll events.
Public propertyTag Gets or sets the custom data property.

Methods

NameDescription
Protected methodAwake Sets up the internal references.
Public methodOnBeginDrag Method called by Unity when the control started being dragged. (Overrides EventTrigger.OnBeginDrag(PointerEventData).)
Public methodOnCancel Method called by Unity when a Cancel event was sent to control. (Overrides EventTrigger.OnCancel(BaseEventData).)
Protected methodOnClicked Overridable event trigger for Clicked and GlobalClicked.
Protected methodOnCursorEntered Overridable event trigger for CursorEntered.
Protected methodOnCursorExited Overridable event trigger for CursorExited.
Public methodOnDeselect Method called by Unity when the control was deselected. (Overrides EventTrigger.OnDeselect(BaseEventData).)
Protected methodOnDestroy Unity OnDestroy() method.
Protected methodOnDisable Unity OnDisable() method.
Public methodOnDrag Method called by Unity each frame the control is being dragged. (Overrides EventTrigger.OnDrag(PointerEventData).)
Protected methodOnDragEnded Overridable event trigger for DragEnded and GlobalDragEnded.
Protected methodOnDragged Overridable event trigger for Dragged and GlobalDragged.
Protected methodOnDragStarted Overridable event trigger for DragStarted and GlobalDragStarted.
Public methodOnDrop Method called by Unity when the control was dropped. (Overrides EventTrigger.OnDrop(PointerEventData).)
Protected methodOnDropped Overridable event trigger for Dropped.
Protected methodOnEnable Unity OnEnable() method.
Public methodOnEndDrag Method called by Unity when a drag event ended on the control. (Overrides EventTrigger.OnEndDrag(PointerEventData).)
Public methodOnInitializePotentialDrag Method called by Unity when a potential drag could be started on the the control but the drag did not start yet. (Overrides EventTrigger.OnInitializePotentialDrag(PointerEventData).)
Protected methodOnInputSubmitted Overridable event trigger for InputSubmitted.
Public methodOnMove Method called when navigating through the control. (Overrides EventTrigger.OnMove(AxisEventData).)
Public methodOnPointerClick Method called by Unity when the control was clicked. A click depending on the operating mode can be a press or a release after a press. (Overrides EventTrigger.OnPointerClick(PointerEventData).)
Public methodOnPointerDown Method called by Unity when the control was pressed. (Overrides EventTrigger.OnPointerDown(PointerEventData).)
Public methodOnPointerEnter Method called by Unity when the cursor entered the control rect. (Overrides EventTrigger.OnPointerEnter(PointerEventData).)
Public methodOnPointerExit Method called by Unity when the cursor exited the control rect. (Overrides EventTrigger.OnPointerExit(PointerEventData).)
Public methodOnPointerUp Method called by Unity when the control was released after being pressed. (Overrides EventTrigger.OnPointerUp(PointerEventData).)
Protected methodOnPressed Overridable event trigger for Pressed and GlobalPressed.
Protected methodOnReleased Overridable event trigger for Released and GlobalReleased.
Public methodOnScroll Method called by Unity when the content was scrolled on the control. (Overrides EventTrigger.OnScroll(PointerEventData).)
Public methodOnSelect Method called by Unity when the control was selected. (Overrides EventTrigger.OnSelect(BaseEventData).)
Public methodOnSubmit Method called by Unity when the content of an InputField was validated (OK was pressed) on the control. (Overrides EventTrigger.OnSubmit(BaseEventData).)
Public methodOnUpdateSelected Method called by Unity when the content of an InputField was updated on the control. (Overrides EventTrigger.OnUpdateSelected(BaseEventData).)
Public methodStatic memberReadControl Creates an awaitable task that blocks until a control is clicked.
Public methodStatic memberReadControls Creates an awaitable task that blocks until a control from a given set is clicked, and returns the control that was clicked.
Protected methodReset Resets the component.
Protected methodStart Unity Start() method.
Protected methodUpdate Checks for the press held event.
Public methodStatic memberWaitForClick Creates an awaitable task that blocks until a control is clicked.

Events

NameDescription
Public eventClicked Event called whenever the control was clicked. A click depending on the operating mode can be a press or a release after a press.
Public eventCursorEntered Event called whenever the pointer entered the control.
Public eventCursorExited Event called whenever the pointer exited the control.
Public eventDragEnded Event called whenever the control stopped being dragged.
Public eventDragged Event called each frame the control is being dragged.
Public eventDragStarted Event called whenever the control started being dragged.
Public eventDropped Event called whenever the control was dropped.
Public eventStatic memberGlobalClicked Event called whenever any UxrControlInput is clicked. A click depending on the operating mode can be a press or a release after a press.
Public eventStatic memberGlobalDragEnded Event called whenever any UxrControlInput stopped being dragged.
Public eventStatic memberGlobalDragged Event called during the frames any UxrControlInput is being dragged.
Public eventStatic memberGlobalDragStarted Event called whenever any UxrControlInput started being dragged.
Public eventStatic memberGlobalPressed Event called whenever any UxrControlInput is pressed.
Public eventStatic memberGlobalReleased Event called whenever any UxrControlInput press is released.
Public eventInputSubmitted Event called whenever the control’s input field was submitted (OK was pressed).
Public eventPressed Event called whenever the control was pressed.
Public eventPressHeld Event called whenever the control was kept being pressed for PressAndHoldDuration seconds without being dragged.
Public eventReleased Event called whenever the control was released after being pressed.
Public eventUpdateSelected Event called whenever the selected control’s input field is updated/changed.

Extension Methods

NameDescription
Public Extension MethodCheckSetEnabled Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.)
Public Extension MethodGetOrAddComponent<T> Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.)
Public Extension MethodGetPathUnderScene Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.)
Public Extension MethodGetSceneUid Gets an unique identifier string for the given component. (Defined by ComponentExt.)
Public Extension MethodGetUniqueScenePath Gets an unique path in the scene for the given component. It will include scene name, sibling and component indices to make it unique. (Defined by ComponentExt.)
Public Extension MethodLoopCoroutine Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.)
Public Extension MethodSafeGetComponentInParent<T> Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab (Defined by ComponentExt.)
Public Extension MethodShowInInspector(Boolean)Overloaded.
Controls whether to show the current object in the inspector. (Defined by ObjectExt.)
Public Extension MethodShowInInspector(Boolean, Boolean)Overloaded.
Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.)
Public Extension MethodThrowIfNull Throws an exception if the object is null. (Defined by ObjectExt.)

See Also

Reference

UltimateXR.UI.UnityInputModule.Controls Namespace