UnityGUI 输入和处理事件的类型。
使用它来辨别在 GUI 中发生了哪种类型的事件。Events 类型包括鼠标点击、鼠标拖动、按下按钮、鼠标进入或退出窗口、滚轮以及以下提到的其他类型。
另请参阅:Event.type、Event、GUI Scripting Guide。
//Attach this script to a GameObject //This script is a basic overview of some of the Event Types available. It outputs messages depending on the current Event Type.
using UnityEngine;
public class Example : MonoBehaviour { void OnGUI() { Event m_Event = Event.current;
if (m_Event.type == EventType.MouseDown) { Debug.Log("Mouse Down."); }
if (m_Event.type == EventType.MouseDrag) { Debug.Log("Mouse Dragged."); }
if (m_Event.type == EventType.MouseUp) { Debug.Log("Mouse Up."); } } }
| MouseDown | 按下了鼠标键。 |
| MouseUp | 释放了鼠标键。 |
| MouseMove | 移动了鼠标(仅限 Editor 视图)。 |
| MouseDrag | 拖动了鼠标。 |
| KeyDown | 按下了一个键盘键。 |
| KeyUp | 释放了一个键盘键。 |
| ScrollWheel | 移动了滚轮。 |
| Repaint | 重绘事件。每一帧都发送一个。 |
| Layout | 布局事件。 |
| DragUpdated | 仅限 Editor:拖放操作已更新。 |
| DragPerform | 仅限 Editor:拖放操作已执行。 |
| DragExited | 仅限 Editor:拖放操作已退出。 |
| Ignore | 应忽略 Event。 |
| Used | 已经处理了事件。 |
| ValidateCommand | 验证特殊命令(例如复制和粘贴)。 |
| ExecuteCommand | 执行特殊命令(例如复制和粘贴)。 |
| ContextClick | 用户已点击了右键(或者在 Mac 上点击了 Control)。 |
| MouseEnterWindow | 鼠标进入了某个窗口(仅限 Editor 视图)。 |
| MouseLeaveWindow | 鼠标离开了某个窗口(仅限 Editor 视图)。 |
| TouchDown | Direct manipulation device (finger, pen) touched the screen. |
| TouchUp | Direct manipulation device (finger, pen) left the screen. |
| TouchMove | Direct manipulation device (finger, pen) moved on the screen (drag). |
| TouchEnter | Direct manipulation device (finger, pen) moving into the window (drag). |
| TouchLeave | Direct manipulation device (finger, pen) moved out of the window (drag). |
| TouchStationary | Direct manipulation device (finger, pen) stationary event (long touch down). |