当前位置:网站首页>Unity Editor Extension - event handling
Unity Editor Extension - event handling
2022-07-03 08:26:00 【T.D.C】
Event handling
- classification
- Keyboard events
- Mouse events
- Get events
var evt = Event.current;
FAQ
- Input Is the event mechanism of still effective in Editor Mode ?
- It doesn't work
Code
- No, I want to write about water , The mechanism of this module is quite simple , But when developing, there are many business event processing is not simple .
- The following code shows how to handle events in the editor
using System;
using UnityEditor;
using UnityEngine;
namespace DC.DCIMGUIBox
{
public class EventProcessWindow : EditorWindow
{
[MenuItem("DC/IMGUI/EventProcessWindow")]
public static void Open()
{
var window = GetWindow<EventProcessWindow>();
window.minSize = new Vector2(800, 600);
}
private string content = "";
private Vector2 scrollVPos;
public void OnGUI()
{
var evt = Event.current;
content += string.Format("evt.type {0}, {1}\n", Enum.GetName(typeof(EventType), evt.type),
Enum.GetName(typeof(EventType), evt.rawType));
if (content.Length > 1000)
{
content = content.Substring(content.Length - 1000);
}
if (evt.type == EventType.MouseDrag)
{
Debug.Log(evt.mousePosition);
}
scrollVPos = GUILayout.BeginScrollView(scrollVPos, GUILayout.Height(400));
GUILayout.TextArea(content);
GUILayout.EndScrollView();
if (GUILayout.Button("Test Input"))
{
Debug.Log("Input.mousePosition " + Input.mousePosition);
}
if (Input.GetKeyDown(KeyCode.A))
{
Debug.Log("key down a");
}
}
}
}
边栏推荐
- One dimensional array two dimensional array (sort Max insert sort)
- Use filechannel to copy files
- 【音视频】ijkplayer错误码
- [cloud native] introduction and use of feign of microservices
- Redis的数据结构
- KunlunBase MeetUP 等您来!
- UE4 plug in development
- Delete the last character of the string in golang
- Haproxy+kept cluster setup 02
- [set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
猜你喜欢
Base64编码简介
C language - Introduction - essence Edition - take you into programming (I)
Data analysis exercises
Basic operation and process control
Mxone Pro adaptive 2.0 film and television template watermelon video theme apple cmsv10 template
Shader foundation 01
Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
Transplantation of freetype Library
100 GIS practical application cases (78) - Multi compliance database design and data warehousing
matlab神經網絡所有傳遞函數(激活函數)公式詳解
随机推荐
數據庫應用技術課程設計之商城管理系統
C语言-入门-精华版-带你走进编程(一)
Data analysis exercises
Shader foundation 01
[audio and video] ijkplayer error code
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
What does (+) in Oracle mean
Cesium service deployment, and import and display local 3dfiles data
Golang url的编码和解码
Initial unity
P2704 [noi2001] artillery position (shape pressure DP)
Transplantation of freetype Library
redis集群系列四
Chocolate installation
Mysql容器化(1)Docker安装MySQL
CLion-Toolchains are not configured Configure Disable profile问题解决
梯度下降法求解BP神经网络的简单Demo
Golang string segmentation, substitution and interception
Unity4.3.1 engine source code compilation process
Introduction to Base64 coding