This script should be attached to each camera that's used to draw the objects with UI components on them. This may mean only one camera (main camera or your UI camera), or multiple cameras if you happen to have multiple viewports. Failing to attach this script simply means that objects drawn by this camera won't receive UI notifications:
More...
|
static bool | IsPressed (GameObject go) |
| Returns 'true' if any of the active touch, mouse or controller is currently holding the specified object. More...
|
|
static bool | Raycast (Vector3 inPos) |
| Returns the object under the specified position. More...
|
|
static bool | IsHighlighted (GameObject go) |
| Whether the specified object should be highlighted. More...
|
|
static UICamera | FindCameraForLayer (int layer) |
| Find the camera responsible for handling events on objects of the specified layer. More...
|
|
static void | Notify (GameObject go, string funcName, object obj) |
| Generic notification function. Used in place of SendMessage to shorten the code and allow for more than one receiver. More...
|
|
static MouseOrTouch | GetMouse (int button) |
| Get the details of the specified mouse button. More...
|
|
static MouseOrTouch | GetTouch (int id) |
| Get or create a touch event. More...
|
|
static void | RemoveTouch (int id) |
| Remove a touch event from the list. More...
|
|
|
EventType | eventType = EventType.UI_3D |
| Event type – use "UI" for your user interfaces, and "World" for your game camera. This setting changes how raycasts are handled. Raycasts have to be more complicated for UI cameras. More...
|
|
LayerMask | eventReceiverMask = -1 |
| Which layers will receive events. More...
|
|
bool | debug = false |
| If 'true', currently hovered object will be shown in the top left corner. More...
|
|
bool | useMouse = true |
| Whether the mouse input is used. More...
|
|
bool | useTouch = true |
| Whether the touch-based input is used. More...
|
|
bool | allowMultiTouch = true |
| Whether multi-touch is allowed. More...
|
|
bool | useKeyboard = true |
| Whether the keyboard events will be processed. More...
|
|
bool | useController = true |
| Whether the joystick and controller events will be processed. More...
|
|
bool | stickyTooltip = true |
| Whether the tooltip will disappear as soon as the mouse moves (false) or only if the mouse moves outside of the widget's area (true). More...
|
|
float | tooltipDelay = 1f |
| How long of a delay to expect before showing the tooltip. More...
|
|
float | mouseDragThreshold = 4f |
| How much the mouse has to be moved after pressing a button before it starts to send out drag events. More...
|
|
float | mouseClickThreshold = 10f |
| How far the mouse is allowed to move in pixels before it's no longer considered for click events, if the click notification is based on delta. More...
|
|
float | touchDragThreshold = 40f |
| How much the mouse has to be moved after pressing a button before it starts to send out drag events. More...
|
|
float | touchClickThreshold = 40f |
| How far the touch is allowed to move in pixels before it's no longer considered for click events, if the click notification is based on delta. More...
|
|
float | rangeDistance = -1f |
| Raycast range distance. By default it's as far as the camera can see. More...
|
|
string | scrollAxisName = "Mouse ScrollWheel" |
| Name of the axis used for scrolling. More...
|
|
string | verticalAxisName = "Vertical" |
| Name of the axis used to send up and down key events. More...
|
|
string | horizontalAxisName = "Horizontal" |
| Name of the axis used to send left and right key events. More...
|
|
KeyCode | submitKey0 = KeyCode.Return |
| Various keys used by the camera. More...
|
|
KeyCode | submitKey1 = KeyCode.JoystickButton0 |
|
KeyCode | cancelKey0 = KeyCode.Escape |
|
KeyCode | cancelKey1 = KeyCode.JoystickButton1 |
|
|
static BetterList< UICamera > | list = new BetterList<UICamera>() |
| List of all active cameras in the scene. More...
|
|
static GetKeyStateFunc | GetKeyDown = Input.GetKeyDown |
| GetKeyDown function – return whether the specified key was pressed this Update(). More...
|
|
static GetKeyStateFunc | GetKeyUp = Input.GetKeyUp |
| GetKeyDown function – return whether the specified key was released this Update(). More...
|
|
static GetKeyStateFunc | GetKey = Input.GetKey |
| GetKey function – return whether the specified key is currently held. More...
|
|
static GetAxisFunc | GetAxis = Input.GetAxis |
| GetAxis function – return the state of the specified axis. More...
|
|
static OnScreenResize | onScreenResize |
| Delegate triggered when the screen size changes for any reason. Subscribe to it if you don't want to compare Screen.width and Screen.height each frame. More...
|
|
static OnCustomInput | onCustomInput |
| Custom input processing logic, if desired. For example: WP7 touches. Use UICamera.current to get the current camera. More...
|
|
static bool | showTooltips = true |
| Whether tooltips will be shown or not. More...
|
|
static Vector2 | lastTouchPosition = Vector2.zero |
| Position of the last touch (or mouse) event. More...
|
|
static Vector3 | lastWorldPosition = Vector3.zero |
| Position of the last touch (or mouse) event in the world. More...
|
|
static RaycastHit | lastHit |
| Last raycast hit prior to sending out the event. This is useful if you want detailed information about what was actually hit in your OnClick, OnHover, and other event functions. Note that this is not going to be valid if you're using 2D colliders. More...
|
|
static UICamera | current = null |
| UICamera that sent out the event. More...
|
|
static Camera | currentCamera = null |
| Last camera active prior to sending out the event. This will always be the camera that actually sent out the event. More...
|
|
static ControlScheme | currentScheme = ControlScheme.Mouse |
| Current control scheme. Set automatically when events arrive. More...
|
|
static int | currentTouchID = -1 |
| ID of the touch or mouse operation prior to sending out the event. Mouse ID is '-1' for left, '-2' for right mouse button, '-3' for middle. More...
|
|
static KeyCode | currentKey = KeyCode.None |
| Key that triggered the event, if any. More...
|
|
static MouseOrTouch | currentTouch = null |
| Current touch, set before any event function gets called. More...
|
|
static bool | inputHasFocus = false |
| Whether an input field currently has focus. More...
|
|
static GameObject | genericEventHandler |
| If set, this game object will receive all events regardless of whether they were handled or not. More...
|
|
static GameObject | fallThrough |
| If events don't get handled, they will be forwarded to this game object. More...
|
|
static MouseOrTouch | controller = new MouseOrTouch() |
|
static bool | isDragging = false |
| Set to 'true' just before OnDrag-related events are sent. No longer needed, but kept for backwards compatibility. More...
|
|
static GameObject | hoveredObject |
| The object hit by the last Raycast that was the result of a mouse or touch event. More...
|
|
This script should be attached to each camera that's used to draw the objects with UI components on them. This may mean only one camera (main camera or your UI camera), or multiple cameras if you happen to have multiple viewports. Failing to attach this script simply means that objects drawn by this camera won't receive UI notifications:
- OnHover (isOver) is sent when the mouse hovers over a collider or moves away.
- OnPress (isDown) is sent when a mouse button gets pressed on the collider.
- OnSelect (selected) is sent when a mouse button is first pressed on an object. Repeated presses won't result in an OnSelect(true).
- OnClick () is sent when a mouse is pressed and released on the same object. UICamera.currentTouchID tells you which button was clicked.
- OnDoubleClick () is sent when the click happens twice within a fourth of a second. UICamera.currentTouchID tells you which button was clicked.
- OnDragStart () is sent to a game object under the touch just before the OnDrag() notifications begin.
- OnDrag (delta) is sent to an object that's being dragged.
- OnDragOver (draggedObject) is sent to a game object when another object is dragged over its area.
- OnDragOut (draggedObject) is sent to a game object when another object is dragged out of its area.
- OnDragEnd () is sent to a dragged object when the drag event finishes.
- OnTooltip (show) is sent when the mouse hovers over a collider for some time without moving.
- OnScroll (float delta) is sent out when the mouse scroll wheel is moved.
- OnKey (KeyCode key) is sent when keyboard or controller input is used.