Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Event

A UnityGUI event.
Read time 2 minutesLast updated 5 days ago

Definition

  • Type: Class
  • Namespace: UnityEngine
  • Assembly: UnityEngine.IMGUIModule
public sealed class Event

Remarks

Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events.
For each event MonoBehaviour.OnGUI() is called in the scripts; so OnGUI is potentially called multiple times per frame. Event.current corresponds to "current" event inside OnGUI call.
Additional Resources: GUI Scripting Guide, EventType.

Properties

Property

Description

altIs Alt/Option key held down? (Read Only)
buttonWhich mouse button was pressed.
capsLockIs Caps Lock on? (Read Only)
characterThe character typed.
clickCountHow many consecutive mouse clicks have we received.
commandIs Command/Windows key held down? (Read Only)
commandNameThe name of an ExecuteCommand or ValidateCommand Event.
controlIs Control key held down? (Read Only)
deltaThe relative movement of the mouse compared to last event.
displayIndexIndex of display that the event belongs to.
functionKeyIs the current keypress a function key? (Read Only)
isKeyIs this event a keyboard event? (Read Only)
isMouseIs this event a mouse event? (Read Only)
keyCodeThe raw key code for keyboard events.
modifiersWhich modifier keys are held down.
mousePositionThe mouse position.
numericIs the current keypress on the numeric keyboard? (Read Only)
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.
pointerTypeThe type of pointer that created this event (for example, mouse, touch screen, pen).
pressureHow hard pen pressure is applied, normalized between 0 (no pressure) and 1 (maximum pressure).
shiftIs Shift held down? (Read Only)
tiltSpecifies the angle of the pen relative to the X and Y axes, expressed in radians.
twistSpecifies the rotation of the pen around its axis, expressed in radians. The default value is 0.
typeThe type of event.

Static Properties

Property

Description

currentThe current event that's being processed right now.

Methods

Method

Description

GetTypeForControlGet a filtered event type for a given control ID.
UseUse this event.

Static Methods

Method

Description

GetEventCountReturns the current number of events that are stored in the event queue.
KeyboardEventCreate a keyboard event.
PopEventGet the next queued [Event] from the event system.