Class PointerEventData
Each touch event creates one of these containing all the relevant information.
Inherited Members
Namespace: UnityEngine.EventSystems
Assembly: UnityEngine.UI.dll
Syntax
public class PointerEventData : BaseEventData
Constructors
PointerEventData(EventSystem)
Declaration
public PointerEventData(EventSystem eventSystem)
Parameters
| Type | Name | Description |
|---|---|---|
| EventSystem | eventSystem |
See Also
Fields
hovered
Declaration
public List<GameObject> hovered
Field Value
| Type | Description |
|---|---|
| List<GameObject> |
Properties
altitudeAngle
The angle of the stylus relative to the surface, in radians
Declaration
public float altitudeAngle { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
A value of 0 indicates that the stylus is parallel to the surface. A value of pi/2 indicates that it is perpendicular to the surface.
See Also
azimuthAngle
The angle of the stylus relative to the x-axis, in radians.
Declaration
public float azimuthAngle { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
A value of 0 indicates that the stylus is pointed along the x-axis of the device.
See Also
button
The EventSystems.PointerEventData.InputButton for this event.
Declaration
public PointerEventData.InputButton button { get; set; }
Property Value
| Type | Description |
|---|---|
| PointerEventData.InputButton |
clickCount
Number of clicks in a row.
Declaration
public int clickCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.
public class ExampleClass : MonoBehaviour, IPointerDownHandler
{
public void OnPointerDown(PointerEventData eventData)
{
//Grab the number of consecutive clicks and assign it to an integer varible.
int i = eventData.clickCount;
//Display the click count.
Debug.Log(i);
}
}
clickTime
The last time a click event was sent. Used for double click
Declaration
public float clickTime { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
delta
Pointer delta since last update.
Declaration
public Vector2 delta { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
displayIndex
The index of the display that this pointer event comes from.
Declaration
public int displayIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
dragging
Is a drag operation currently occuring.
Declaration
public bool dragging { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
eligibleForClick
Is it possible to click this frame
Declaration
public bool eligibleForClick { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
enterEventCamera
The camera associated with the last OnPointerEnter event.
Declaration
public Camera enterEventCamera { get; }
Property Value
| Type | Description |
|---|---|
| Camera |
fullyExited
Specifies in the case of a pointer exit if the pointer has fully exited the area or if it has just entered a child.
Declaration
public bool fullyExited { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
lastPress
The raw GameObject for the last press event. This means that it is the 'pressed' GameObject even if it can not receive the press event itself.
Declaration
public GameObject lastPress { get; }
Property Value
| Type | Description |
|---|---|
| GameObject |
penStatus
Specifies the state of the pen. For example, whether the pen is in contact with the screen or tablet, whether the pen is inverted, and whether buttons are pressed.
Declaration
public PenStatus penStatus { get; set; }
Property Value
| Type | Description |
|---|---|
| PenStatus |
See Also
pointerClick
The object that should receive the 'OnPointerClick' event.
Declaration
public GameObject pointerClick { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
pointerCurrentRaycast
RaycastResult associated with the current event.
Declaration
public RaycastResult pointerCurrentRaycast { get; set; }
Property Value
| Type | Description |
|---|---|
| RaycastResult |
pointerDrag
The object that is receiving 'OnDrag'.
Declaration
public GameObject pointerDrag { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
pointerEnter
The object that received 'OnPointerEnter'.
Declaration
public GameObject pointerEnter { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
pointerId
Id of the pointer (touch id).
Declaration
public int pointerId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
pointerPress
The GameObject that received the OnPointerDown.
Declaration
public GameObject pointerPress { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
pointerPressRaycast
RaycastResult associated with the pointer press.
Declaration
public RaycastResult pointerPressRaycast { get; set; }
Property Value
| Type | Description |
|---|---|
| RaycastResult |
position
Current pointer position.
Declaration
public Vector2 position { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
pressEventCamera
The camera associated with the last OnPointerPress event.
Declaration
public Camera pressEventCamera { get; }
Property Value
| Type | Description |
|---|---|
| Camera |
pressPosition
Position of the press.
Declaration
public Vector2 pressPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
pressure
The amount of pressure currently applied by a touch.
Declaration
public float pressure { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
If the device does not report pressure, the value of this property is 1.0f.
See Also
radius
An estimate of the radius of a touch.
Declaration
public Vector2 radius { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Remarks
Add radiusVariance to get the maximum touch radius, subtract it to get the minimum touch radius.
See Also
radiusVariance
The accuracy of the touch radius.
Declaration
public Vector2 radiusVariance { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Remarks
Add this value to the radius to get the maximum touch radius, subtract it to get the minimum touch radius.
rawPointerPress
The object that the press happened on even if it can not handle the press event.
Declaration
public GameObject rawPointerPress { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
reentered
Specifies in the case of a pointer enter if the pointer has entered a new area or if it has just reentered a parent after leaving a child.
Declaration
public bool reentered { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
scrollDelta
The amount of scroll since the last update.
Declaration
public Vector2 scrollDelta { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
tangentialPressure
The pressure applied to an additional pressure-sensitive control on the stylus.
Declaration
public float tangentialPressure { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
tilt
Specifies the angle of the pen relative to the X & Y axis, in radians.
Declaration
public Vector2 tilt { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
See Also
twist
The rotation of the stylus around its axis, in radians.
Declaration
public float twist { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
useDragThreshold
Should a drag threshold be used?
Declaration
public bool useDragThreshold { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
If you do not want a drag threshold set this to false in IInitializePotentialDragHandler.OnInitializePotentialDrag.
worldNormal
World-space normal where a ray cast into the screen hits something
Declaration
[Obsolete("Use either pointerCurrentRaycast.worldNormal or pointerPressRaycast.worldNormal")]
public Vector3 worldNormal { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
worldPosition
World-space position where a ray cast into the screen hits something
Declaration
[Obsolete("Use either pointerCurrentRaycast.worldPosition or pointerPressRaycast.worldPosition")]
public Vector3 worldPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Methods
IsPointerMoving()
Is the pointer moving.
Declaration
public bool IsPointerMoving()
Returns
| Type | Description |
|---|---|
| bool |
IsScrolling()
Is scroll being used on the input device.
Declaration
public bool IsScrolling()
Returns
| Type | Description |
|---|---|
| bool |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |