This class manages input such as clicking, hovering and keypresses.
Static Public Member Functions | |
static void | Clear () |
Clears all active elements. More... | |
static void | ClearMouseOvers (UIEvent mouseEvent, int fromIndex) |
Clears mouse overs from the list and calls onmouseout with the given event. More... | |
static void | SetMousePosition (Vector2 position) |
Used internally. Don't call this from within a 2D resolver. Locates the mouse at the given position. More... | |
static void | Update () |
Updates mouse overs and the mouse position. More... | |
static bool | OnKeyUp (int keyCode, char character) |
Tells the UI a key was released. More... | |
static bool | OnKeyDown (int keyCode, char character) |
Tells the UI a key was pressed down. More... | |
static bool | OnKeyPress (bool down, char character, int keyCode) |
Tells the UI a key was pressed. More... | |
static bool | OnMouseDown (int x, int y) |
Tells the UI the mouse was clicked. More... | |
static bool | OnMouseUp (int x, int y) |
Tells the UI the mouse was released. More... | |
static void | ClickOn (Element element, UIEvent uiEvent) |
Runs a click which may bubble all the way to the root from the given element. More... | |
static void | MouseOn (Element element, UIEvent uiEvent) |
Runs a mouseover which may bubble all the way to the root from the given element. More... | |
static bool | OnMouseOver (int x, int y) |
Checks if the mouse is over the UI and runs the mouse over methods. More... | |
static HitResult | HandleUIHit (RaycastHit hit) |
Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true. More... | |
static HitResult | HandleWorldUIHit (RaycastHit hit) |
Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true. More... | |
Static Public Attributes | |
static int | MouseX |
The computed mouseX coordinate on the currently focused UI. May originate from a raycast for WorldUIs. More... | |
static int | MouseY |
The computed mouseY coordinate on the currently focused UI. May originate from a raycast for WorldUIs. More... | |
static Element | Focused |
The currently focused element. More... | |
static Element | Focusing |
The currently focusing element. More... | |
static Vector2 | MousePosition |
The position of the mouse in pixels from the top left corner. More... | |
static RaycastHit | LatestRayHit |
If WorldUI's receive input, a ray must be fired from CameraFor3DInput to attempt input. This is the lastest ray result. UI.MouseOver updates this immediately; it's updated at the UI rate otherwise. More... | |
static Camera | CameraFor3DInput |
The camera used for 3D input. Defaults to Camera.main if this is null. More... | |
static InputMode | Mode =InputMode.Screen |
The mode of input. Use UI.InputMode to change this correctly. This defines how a click/tap should be resolved to an element. More... | |
static MousePositionResolver2D | OnResolve2D |
Used to resolve the 2D location of the mouse. If used, apply your results to MousePosition. More... | |
static MousePositionResolver3D | OnResolve3D |
Used to resolve the 3D location of the mouse. More... | |
static InputMode | WorldInputMode =InputMode.None |
The mode of input for worldUI's. More... | |
static List< Element > | MouseOvers =new List<Element>() |
The set of all elements that currently have the mouse over them. This is essentially a stack; The element at the front of the list is the element on top. This is because the event bubbles upwards starting at the deepest element in the DOM. More... | |
static List< Element > | LastMouseDown =new List<Element>() |
The latest elements to receive a mousedown. More than one because it's possible to click on a whole bunch of elements at the same time. More... | |
Properties | |
static bool | MouseOverUI [get] |
True if the mouse is over any element on the UI. More... | |
Static Private Member Functions | |
static bool | RunClick (int x, int y, bool mouseDown, out UIEvent uiEvent) |
Tells the UI the mouse was clicked or released. More... | |
|
inlinestatic |
Clears all active elements.
|
inlinestatic |
Clears mouse overs from the list and calls onmouseout with the given event.
mouseEvent | The event to use for mouse out calls. |
fromIndex | The (inclusive) index to start clearing from. 0 clears the whole list. |
Runs a click which may bubble all the way to the root from the given element.
element | The element to run a click on. |
uiEvent | The event that represents the click. |
|
inlinestatic |
Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.
hit | The successful raycast hit. |
|
inlinestatic |
Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.
hit | The successful raycast hit. |
Runs a mouseover which may bubble all the way to the root from the given element.
element | The element to run a mouseover on. |
uiEvent | The event that represents the click. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestaticprivate |
|
inlinestatic |
Used internally. Don't call this from within a 2D resolver. Locates the mouse at the given position.
|
inlinestatic |
Updates mouse overs and the mouse position.
|
static |
The camera used for 3D input. Defaults to Camera.main if this is null.
|
static |
The currently focused element.
|
static |
The currently focusing element.
The latest elements to receive a mousedown. More than one because it's possible to click on a whole bunch of elements at the same time.
|
static |
If WorldUI's receive input, a ray must be fired from CameraFor3DInput to attempt input. This is the lastest ray result. UI.MouseOver updates this immediately; it's updated at the UI rate otherwise.
|
static |
The mode of input. Use UI.InputMode to change this correctly. This defines how a click/tap should be resolved to an element.
The set of all elements that currently have the mouse over them. This is essentially a stack; The element at the front of the list is the element on top. This is because the event bubbles upwards starting at the deepest element in the DOM.
|
static |
The position of the mouse in pixels from the top left corner.
|
static |
The computed mouseX coordinate on the currently focused UI. May originate from a raycast for WorldUIs.
|
static |
The computed mouseY coordinate on the currently focused UI. May originate from a raycast for WorldUIs.
|
static |
Used to resolve the 2D location of the mouse. If used, apply your results to MousePosition.
|
static |
Used to resolve the 3D location of the mouse.
|
static |
The mode of input for worldUI's.
|
staticget |
True if the mouse is over any element on the UI.