Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PointerEventBase<T>

Base class for all pointer-related events.
Read time 4 minutesLast updated 5 days ago

Definition

public abstract class PointerEventBase<T> : EventBase<T>, IDisposable, IPointerEvent where T : PointerEventBase<T>, new()

Remarks

Pointer events are sent when a user interacts with the mouse, touchscreen, or digital pens.
By default, pointer events trickle down the hierarchy of visual elements and then bubble up back to the root.
A cycle of pointer events occurs as follows:
  • The user presses a mouse button, touches the screen, or otherwise causes a PointerDownEvent to be sent.
  • If the user changes the pointer's state, a PointerMoveEvent is sent. Multiple PointerMove events are sent if multiple properties of the pointer change.
  • If the user cancels the loop, a PointerCancelEvent is sent.
  • If the user doesn't cancel the loop, and either releases the last button pressed or releases the last touch, a PointerUpEvent is sent.
  • If the initial PointerDownEvent and the PointerUpEvent occur on the same visual element, a ClickEvent is sent.
Refer to the Pointer events manual page for more information and examples.

Properties

Property

Description

actionKeyGets a boolean value that indicates whether the platform-specific action key is pressed.
altitudeAngleGets the angle of the stylus relative to the surface, in radians
altKeyGets a boolean value that indicates whether the Alt key is pressed.
azimuthAngleGets the angle of the stylus relative to the x-axis, in radians.
buttonGets a value that indicates which mouse button was pressed or released (if any) to cause this event: 0 is the left button, 1 is the right button, 2 is the middle button. A negative value indicates that no mouse button changed state during this event.
clickCountGets the number of consecutive times a down-up sequence was executed in a short amount of time with the same pointer ID and button.
commandKeyGets a boolean value that indicates whether the Windows/Cmd key is pressed.
ctrlKeyGets a boolean value that indicates whether the Ctrl key is pressed.
currentTargetGets the current target of the event.
deltaPositionGets the difference between the pointer's position during the previous pointer event and its position during the current pointer event.
deltaTimeGets the amount of time that has elapsed since the last recorded change in pointer values, in seconds.
isPrimaryGets a boolean value that indicates whether the pointer is a primary pointer. True means the pointer is a primary pointer. False means it isn't.
localPositionGets the pointer position in the current target's coordinate system.
modifiersGets flags that indicate whether modifier keys (Alt, Ctrl, Shift, Windows/Cmd) are pressed.
penStatusSpecifies 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. On macOS, penStatus will not reflect changes to button mappings.
pointerIdGets the identifier of the pointer that sent the event.
pointerTypeGets the type of pointer that created the event.
positionGets the pointer position in the panel coordinate system.
pressedButtonsGets a bitmask that describes the buttons that are currently pressed.
pressureGets the amount of pressure currently applied by a touch.
radiusGets an estimate of the radius of a touch.
radiusVarianceGets the accuracy of the touch radius.
shiftKeyGets a boolean value that indicates whether the Shift key is pressed.
tangentialPressureGets the pressure applied to an additional pressure-sensitive control on the stylus.
tiltSpecifies the angle of the pen relative to the X and Y axis respectively, in radians.
twistGets the rotation of the stylus around its axis, in radians.

Methods

Method

Description

InitResets the event members to their initial values.

Static Methods

Method

Description

GetPooledGets an event from the event pool and initializes it with the given values. Use this function instead of creating new events. Events obtained using this method need to be released back to the pool. You can use
Dispose()
to release them.

Inheritance