Version: 2023.2
LanguageEnglish
  • C#

Event

class in UnityEngine

/

Implemented in:UnityEngine.IMGUIModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A UnityGUI event.

Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events.

For each event 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.

Static Properties

currentThe current event that's being processed right now.

Properties

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.

Public Methods

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

Static Methods

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.