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
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 | |
| PointerEventData | 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)
Return the last PointerEventData for the given touch / mouse id.
Declaration
protected PointerEventData GetLastPointerEventData(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| PointerEventData |
GetMousePointerEventData()
Return the current MouseState. Using the default pointer.
Declaration
protected virtual PointerInputModule.MouseState GetMousePointerEventData()
Returns
| Type | Description |
|---|---|
| PointerInputModule.MouseState |
GetMousePointerEventData(int)
Return the current MouseState.
Declaration
protected virtual PointerInputModule.MouseState GetMousePointerEventData(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| PointerInputModule.MouseState |
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 | Pointer ID |
Returns
| Type | Description |
|---|---|
| bool | Is the given pointer over an event system 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 |
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 |
RemovePointerData(PointerEventData)
Remove the PointerEventData from the cache.
Declaration
protected void RemovePointerData(PointerEventData data)
Parameters
| Type | Name | Description |
|---|---|---|
| PointerEventData | data |
StateForMouseButton(int)
Given a mouse button return the current state for the frame.
Declaration
protected PointerEventData.FramePressState StateForMouseButton(int buttonId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | buttonId | Mouse button ID |
Returns
| Type | Description |
|---|---|
| PointerEventData.FramePressState |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |