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
Name | Description | |
---|---|---|
UxrControlInput |
Properties
Name | Description | |
---|---|---|
Enabled | Gets or sets whether the object can be interacted with and will send any events. | |
FeedbackOnClick | Gets or sets the feedback when the UI element was clicked. | |
FeedbackOnDown | Gets or sets the feedback when the UI element was pressed. | |
FeedbackOnUp | Gets or sets the feedback when the UI element was released. | |
GameObject | Gets the control’s GameObject | |
Image | Gets the Unity Image component on the same object if it exists. | |
Interactable | Gets or sets whether the widget is interactable or not. The widget should have a Selectable component. | |
IsDragging | Gets whether the control is currently being dragged. | |
PressAndHoldDuration | Gets or sets how many seconds need to pass to trigger a PressHeld event | |
RectTransform | Gets the Unity RectTransform component. | |
ScrollRect | Gets the ScrollRect reference used in drag/scroll events. | |
Tag | Gets or sets the custom data property. |
Methods
Name | Description | |
---|---|---|
Awake | Sets up the internal references. | |
OnBeginDrag | Method called by Unity when the control started being dragged. (Overrides EventTrigger.OnBeginDrag(PointerEventData).) | |
OnCancel | Method called by Unity when a Cancel event was sent to control. (Overrides EventTrigger.OnCancel(BaseEventData).) | |
OnClicked | Overridable event trigger for Clicked and GlobalClicked. | |
OnCursorEntered | Overridable event trigger for CursorEntered. | |
OnCursorExited | Overridable event trigger for CursorExited. | |
OnDeselect | Method called by Unity when the control was deselected. (Overrides EventTrigger.OnDeselect(BaseEventData).) | |
OnDestroy | Unity OnDestroy() method. | |
OnDisable | Unity OnDisable() method. | |
OnDrag | Method called by Unity each frame the control is being dragged. (Overrides EventTrigger.OnDrag(PointerEventData).) | |
OnDragEnded | Overridable event trigger for DragEnded and GlobalDragEnded. | |
OnDragged | Overridable event trigger for Dragged and GlobalDragged. | |
OnDragStarted | Overridable event trigger for DragStarted and GlobalDragStarted. | |
OnDrop | Method called by Unity when the control was dropped. (Overrides EventTrigger.OnDrop(PointerEventData).) | |
OnDropped | Overridable event trigger for Dropped. | |
OnEnable | Unity OnEnable() method. | |
OnEndDrag | Method called by Unity when a drag event ended on the control. (Overrides EventTrigger.OnEndDrag(PointerEventData).) | |
OnInitializePotentialDrag | 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).) | |
OnInputSubmitted | Overridable event trigger for InputSubmitted. | |
OnMove | Method called when navigating through the control. (Overrides EventTrigger.OnMove(AxisEventData).) | |
OnPointerClick | 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).) | |
OnPointerDown | Method called by Unity when the control was pressed. (Overrides EventTrigger.OnPointerDown(PointerEventData).) | |
OnPointerEnter | Method called by Unity when the cursor entered the control rect. (Overrides EventTrigger.OnPointerEnter(PointerEventData).) | |
OnPointerExit | Method called by Unity when the cursor exited the control rect. (Overrides EventTrigger.OnPointerExit(PointerEventData).) | |
OnPointerUp | Method called by Unity when the control was released after being pressed. (Overrides EventTrigger.OnPointerUp(PointerEventData).) | |
OnPressed | Overridable event trigger for Pressed and GlobalPressed. | |
OnReleased | Overridable event trigger for Released and GlobalReleased. | |
OnScroll | Method called by Unity when the content was scrolled on the control. (Overrides EventTrigger.OnScroll(PointerEventData).) | |
OnSelect | Method called by Unity when the control was selected. (Overrides EventTrigger.OnSelect(BaseEventData).) | |
OnSubmit | Method called by Unity when the content of an InputField was validated (OK was pressed) on the control. (Overrides EventTrigger.OnSubmit(BaseEventData).) | |
OnUpdateSelected | Method called by Unity when the content of an InputField was updated on the control. (Overrides EventTrigger.OnUpdateSelected(BaseEventData).) | |
ReadControl | Creates an awaitable task that blocks until a control is clicked. | |
ReadControls | Creates an awaitable task that blocks until a control from a given set is clicked, and returns the control that was clicked. | |
Reset | Resets the component. | |
Start | Unity Start() method. | |
Update | Checks for the press held event. | |
WaitForClick | Creates an awaitable task that blocks until a control is clicked. |
Events
Name | Description | |
---|---|---|
Clicked | Event called whenever the control was clicked. A click depending on the operating mode can be a press or a release after a press. | |
CursorEntered | Event called whenever the pointer entered the control. | |
CursorExited | Event called whenever the pointer exited the control. | |
DragEnded | Event called whenever the control stopped being dragged. | |
Dragged | Event called each frame the control is being dragged. | |
DragStarted | Event called whenever the control started being dragged. | |
Dropped | Event called whenever the control was dropped. | |
GlobalClicked | Event called whenever any UxrControlInput is clicked. A click depending on the operating mode can be a press or a release after a press. | |
GlobalDragEnded | Event called whenever any UxrControlInput stopped being dragged. | |
GlobalDragged | Event called during the frames any UxrControlInput is being dragged. | |
GlobalDragStarted | Event called whenever any UxrControlInput started being dragged. | |
GlobalPressed | Event called whenever any UxrControlInput is pressed. | |
GlobalReleased | Event called whenever any UxrControlInput press is released. | |
InputSubmitted | Event called whenever the control’s input field was submitted (OK was pressed). | |
Pressed | Event called whenever the control was pressed. | |
PressHeld | Event called whenever the control was kept being pressed for PressAndHoldDuration seconds without being dragged. | |
Released | Event called whenever the control was released after being pressed. | |
UpdateSelected | Event called whenever the selected control’s input field is updated/changed. |
Extension Methods
Name | Description | |
---|---|---|
CheckSetEnabled | Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.) | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.) | |
GetPathUnderScene | Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.) | |
GetSceneUid | Gets an unique identifier string for the given component. (Defined by ComponentExt.) | |
GetUniqueScenePath | 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.) | |
LoopCoroutine | Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.) | |
SafeGetComponentInParent<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.) | |
ShowInInspector(Boolean) | Overloaded. Controls whether to show the current object in the inspector. (Defined by ObjectExt.) | |
ShowInInspector(Boolean, Boolean) | Overloaded. Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.) | |
ThrowIfNull | Throws an exception if the object is null. (Defined by ObjectExt.) |