Class PointerInputModule
A BaseInputModule for pointer input.
Inheritance
Inherited Members
Namespace: UnityEngine.EventSystems
Assembly: UnityEngine.UI.dll
Syntax
public abstract class PointerInputModule : BaseInputModule
Fields
kFakeTouchesId
Touch id for when simulating touches on a non touch device.
Declaration
public const int kFakeTouchesId = -4
Field Value
| Type | Description |
|---|---|
| int |
kMouseLeftId
Id of the cached left mouse pointer event.
Declaration
public const int kMouseLeftId = -1
Field Value
| Type | Description |
|---|---|
| int |
kMouseMiddleId
Id of the cached middle mouse pointer event.
Declaration
public const int kMouseMiddleId = -3
Field Value
| Type | Description |
|---|---|
| int |
kMouseRightId
Id of the cached right mouse pointer event.
Declaration
public const int kMouseRightId = -2
Field Value
| Type | Description |
|---|---|
| int |
m_PointerData
The pointer event data for every active pointer, indexed by pointer ID.
Declaration
protected Dictionary<int, PointerEventData> m_PointerData
Field Value
| Type | Description |
|---|---|
| Dictionary<int, PointerEventData> |
Methods
ClearSelection()
Clear all pointers and deselect any selected objects in the EventSystem.
Declaration
protected void ClearSelection()
CopyFromTo(PointerEventData, PointerEventData)
Copy one PointerEventData to another.
Declaration
protected void CopyFromTo(PointerEventData from, PointerEventData to)
Parameters
| Type | Name | Description |
|---|---|---|
| PointerEventData | from | The pointer event data to copy the values from. |
| PointerEventData | to | The pointer event data to copy the values to. |
DeselectIfSelectionChanged(GameObject, BaseEventData)
Deselect the current selected GameObject if the currently pointed-at GameObject is different.
Declaration
protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventData pointerEvent)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | currentOverGo | The GameObject the pointer is currently over. |
| BaseEventData | pointerEvent | Current event data. |
GetLastPointerEventData(int)
Returns the last PointerEventData for the given touch or mouse ID.
Declaration
protected PointerEventData GetLastPointerEventData(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The touch or mouse ID of the pointer event data. |
Returns
| Type | Description |
|---|---|
| PointerEventData | The last pointer event data of the given ID, or null if the pointer isn't tracked. |
GetMousePointerEventData()
Returns the current MouseState for the default pointer.
Declaration
protected virtual PointerInputModule.MouseState GetMousePointerEventData()
Returns
| Type | Description |
|---|---|
| PointerInputModule.MouseState | The mouse state, with the left, right, and middle button data updated for this frame. |
GetMousePointerEventData(int)
Updates and returns the current MouseState.
Declaration
protected virtual PointerInputModule.MouseState GetMousePointerEventData(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Ignored. |
Returns
| Type | Description |
|---|---|
| PointerInputModule.MouseState | The mouse state, with the left, right, and middle button data updated for this frame. |
GetPointerData(int, out PointerEventData, bool)
Search the cache for currently active pointers, return true if found.
Declaration
protected bool GetPointerData(int id, out PointerEventData data, bool create)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Touch ID |
| PointerEventData | data | Found data |
| bool | create | If not found should it be created |
Returns
| Type | Description |
|---|---|
| bool | True if pointer is found. |
GetTouchPointerEventData(Touch, out bool, out bool)
Populates a PointerEventData object using touch input and determines if the touch was pressed or released.
Declaration
protected PointerEventData GetTouchPointerEventData(Touch input, out bool pressed, out bool released)
Parameters
| Type | Name | Description |
|---|---|---|
| Touch | input | The Touch input data to process into pointer event data. |
| bool | pressed | Whether the touch began or is active this frame. |
| bool | released | Whether the touch ended or was canceled this frame. |
Returns
| Type | Description |
|---|---|
| PointerEventData | The PointerEventData for the touch. |
Remarks
Builds or reuses PointerEventData for the touch and updates position, phase, and delta. The out parameters indicate if this frame is a press or release, which the event system uses to fire pointer down/up and click events.
Examples
Get touch data and forward press/release to pointer handlers. Requires an active touch and event system. The following forwards pointer down/up.
Touch t = Input.GetTouch(0);
bool pressed, released;
PointerEventData data = GetTouchPointerEventData(t, out pressed, out released);
if (pressed)
ExecuteEvents.Execute(gameObject, data, ExecuteEvents.pointerDownHandler);
if (released)
ExecuteEvents.Execute(gameObject, data, ExecuteEvents.pointerUpHandler);
IsPointerOverGameObject(int)
If the module is pointer based, then override this to return true if the pointer is over an event system object.
Declaration
public override bool IsPointerOverGameObject(int pointerId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | pointerId | The ID of the pointer. |
Returns
| Type | Description |
|---|---|
| bool | True if the pointer is over an EventSystem object. |
Overrides
ProcessDrag(PointerEventData)
Process the drag for the current frame with the given pointer event.
Declaration
protected virtual void ProcessDrag(PointerEventData pointerEvent)
Parameters
| Type | Name | Description |
|---|---|---|
| PointerEventData | pointerEvent | The pointer event data for the drag. |
ProcessMove(PointerEventData)
Process movement for the current frame with the given pointer event.
Declaration
protected virtual void ProcessMove(PointerEventData pointerEvent)
Parameters
| Type | Name | Description |
|---|---|---|
| PointerEventData | pointerEvent | The pointer event data for the movement. |
RemovePointerData(PointerEventData)
Remove the PointerEventData from the cache.
Declaration
protected void RemovePointerData(PointerEventData data)
Parameters
| Type | Name | Description |
|---|---|---|
| PointerEventData | data | The pointer event data to remove. |
StateForMouseButton(int)
Returns the current state for this frame for a given a mouse button ID.
Declaration
protected PointerEventData.FramePressState StateForMouseButton(int buttonId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | buttonId | Mouse button ID |
Returns
| Type | Description |
|---|---|
| PointerEventData.FramePressState | The press state of the button for this frame. |
ToString()
Returns a multi-line string that lists the state of every tracked pointer.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The formatted description of the input module state. |