Detailed Description

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< ElementMouseOvers =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< ElementLastMouseDown =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...
 

Member Function Documentation

static void PowerUI.Input.Clear ( )
inlinestatic

Clears all active elements.

static void PowerUI.Input.ClearMouseOvers ( UIEvent  mouseEvent,
int  fromIndex 
)
inlinestatic

Clears mouse overs from the list and calls onmouseout with the given event.

Parameters
mouseEventThe event to use for mouse out calls.
fromIndexThe (inclusive) index to start clearing from. 0 clears the whole list.
static void PowerUI.Input.ClickOn ( Element  element,
UIEvent  uiEvent 
)
inlinestatic

Runs a click which may bubble all the way to the root from the given element.

Parameters
elementThe element to run a click on.
uiEventThe event that represents the click.
static HitResult PowerUI.Input.HandleUIHit ( RaycastHit  hit)
inlinestatic

Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.

Parameters
hitThe successful raycast hit.
static HitResult PowerUI.Input.HandleWorldUIHit ( RaycastHit  hit)
inlinestatic

Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.

Parameters
hitThe successful raycast hit.
static void PowerUI.Input.MouseOn ( Element  element,
UIEvent  uiEvent 
)
inlinestatic

Runs a mouseover which may bubble all the way to the root from the given element.

Parameters
elementThe element to run a mouseover on.
uiEventThe event that represents the click.
static bool PowerUI.Input.OnKeyDown ( int  keyCode,
char  character 
)
inlinestatic

Tells the UI a key was pressed down.

Parameters
keyCodeThe keycode of the key
characterThe character entered.
Returns
True if the UI consumed the press.
static bool PowerUI.Input.OnKeyPress ( bool  down,
char  character,
int  keyCode 
)
inlinestatic

Tells the UI a key was pressed.

Parameters
downTrue if the key is now down.
keyCodeThe keycode of the key
characterThe character entered.
Returns
True if the UI consumed the keypress.
static bool PowerUI.Input.OnKeyUp ( int  keyCode,
char  character 
)
inlinestatic

Tells the UI a key was released.

Parameters
keyCodeThe keycode of the key
characterThe character entered.
Returns
True if the UI consumed the release.
static bool PowerUI.Input.OnMouseDown ( int  x,
int  y 
)
inlinestatic

Tells the UI the mouse was clicked.

Parameters
xThe x coordinate of the mouse in pixels from the left of the screen.
yThe y coordinate of the mouse in pixels from the top of the screen.
Returns
True if the mouse was pressed down on the UI.
static bool PowerUI.Input.OnMouseOver ( int  x,
int  y 
)
inlinestatic

Checks if the mouse is over the UI and runs the mouse over methods.

Parameters
xThe x coordinate of the mouse in pixels from the left of the screen.
yThe y coordinate of the mouse in pixels from the top of the screen.
Returns
True if the mouse was over the UI.
static bool PowerUI.Input.OnMouseUp ( int  x,
int  y 
)
inlinestatic

Tells the UI the mouse was released.

Parameters
xThe x coordinate of the mouse in pixels from the left of the screen.
yThe y coordinate of the mouse in pixels from the top of the screen.
Returns
True if the mouse was released on the UI.
static bool PowerUI.Input.RunClick ( int  x,
int  y,
bool  mouseDown,
out UIEvent  uiEvent 
)
inlinestaticprivate

Tells the UI the mouse was clicked or released.

Parameters
xThe x coordinate of the mouse in pixels from the left of the screen.
yThe y coordinate of the mouse in pixels from the top of the screen.
mouseDownTrue if the button is now down.
Returns
True if the mouse was on the UI.
static void PowerUI.Input.SetMousePosition ( Vector2  position)
inlinestatic

Used internally. Don't call this from within a 2D resolver. Locates the mouse at the given position.

static void PowerUI.Input.Update ( )
inlinestatic

Updates mouse overs and the mouse position.

Member Data Documentation

Camera PowerUI.Input.CameraFor3DInput
static

The camera used for 3D input. Defaults to Camera.main if this is null.

Element PowerUI.Input.Focused
static

The currently focused element.

Element PowerUI.Input.Focusing
static

The currently focusing element.

List<Element> PowerUI.Input.LastMouseDown =new List<Element>()
static

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.

RaycastHit PowerUI.Input.LatestRayHit
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.

InputMode PowerUI.Input.Mode =InputMode.Screen
static

The mode of input. Use UI.InputMode to change this correctly. This defines how a click/tap should be resolved to an element.

List<Element> PowerUI.Input.MouseOvers =new List<Element>()
static

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.

Vector2 PowerUI.Input.MousePosition
static

The position of the mouse in pixels from the top left corner.

int PowerUI.Input.MouseX
static

The computed mouseX coordinate on the currently focused UI. May originate from a raycast for WorldUIs.

int PowerUI.Input.MouseY
static

The computed mouseY coordinate on the currently focused UI. May originate from a raycast for WorldUIs.

MousePositionResolver2D PowerUI.Input.OnResolve2D
static

Used to resolve the 2D location of the mouse. If used, apply your results to MousePosition.

MousePositionResolver3D PowerUI.Input.OnResolve3D
static

Used to resolve the 3D location of the mouse.

InputMode PowerUI.Input.WorldInputMode =InputMode.None
static

The mode of input for worldUI's.

Property Documentation

bool PowerUI.Input.MouseOverUI
staticget

True if the mouse is over any element on the UI.