Version: 2023.2

Event

class in UnityEngine

切换到手册

描述

UnityGUI 事件。

事件与用户输入(按键、鼠标操作)相对应,或者是 UnityGUI 布局或渲染事件。

对于每个事件,在这些脚本中均调用 OnGUI;因此每帧可能多次调用 OnGUI。 Event.current 对应于 OnGUI 调用内的“当前”事件。

另请参阅:GUI 脚本指南EventType

静态变量

current将被立即处理的当前事件。

变量

altAlt/Option 键是否被按住?(只读)
button已按下哪个鼠标键。
capsLock是否打开了 Caps Lock?(只读)
character键入的字符。
clickCount已收到了多少次连续鼠标点击。
commandCommand/Windows 键是否被按住?(只读)
commandNameExecuteCommand 或 ValidateCommand 事件的名称。
controlControl 键是否被按住?(只读)
delta与上次事件相比该鼠标的相对移动。
displayIndex该事件所属的显示器的索引。
functionKey当前按键是否是功能键?(只读)
isKey该事件是否是键盘事件?(只读)
isMouse该事件是否是鼠标事件?(只读)
keyCode键盘事件的原始键代码。
modifiers哪些修改键被按住。
mousePosition鼠标位置。
numeric当前按键是否在数字键盘上?(只读)
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.
pointerType创建事件的指针的类型(例如鼠标、触控屏幕、笔)。
pressureHow hard pen pressure is applied, normalized between 0 (no pressure) and 1 (maximum pressure).
shiftShift 键是否被按住?(只读)
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.
type事件的类型。

公共函数

GetTypeForControl获取给定控件 ID 的已筛选事件类型。
Use使用该事件。

静态函数

GetEventCount返回存储在事件队列中的事件的当前数量。
KeyboardEvent创建键盘事件。
PopEvent从事件系统获取排队的下一个 [Event]。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961