当前位置:网站首页>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");
}
}
}
}
边栏推荐
- Vscode, idea, VIM development tool shortcut keys
- C语言-入门-精华版-带你走进编程(一)
- 使用base64编码传图片
- Base64 and base64url
- Minimap plug-in
- 2021-10-19
- P1896 [scoi2005] non aggression (shape pressure DP)
- Pit & ADB wireless debugging of vivo real machine debugging
- Transplantation of tslib Library
- Encoding and decoding of golang URL
猜你喜欢

Display terrain database on osgearth ball

Advanced OSG collision detection

Redis data structure

Unity learning notes

Transplantation of freetype Library

C#课程设计之员工信息管理系统

Mall management system of database application technology course design

Xlua task list youyou

Student educational administration management system of C # curriculum design

Introduction to Base64 coding
随机推荐
Kwai 20200412 recruitment
VIM learning notes from introduction to silk skating
Osgearth starry background
How to establish rectangular coordinate system in space
【更新中】微信小程序学习笔记_3
Why can void * be a general pointer
Golang的range
Swagger document configuration
[linear table] basic operation of bidirectional linked list specify node exchange
Jupyter remote server configuration and server startup
Classes and objects
了解小程序的笔记 2022/7/3
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
Transmit pictures with Base64 encoding
Golang 时间格式整理
Development material set
Lua framwrok framework starts
Luaframwrok handles resource updates
[audio and video] ijkplayer error code
Kunlunbase meetup is waiting for you!