当前位置:网站首页>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");
}
}
}
}
边栏推荐
- Simple demo of solving BP neural network by gradient descent method
- Luaframwrok handles resource updates
- Mall management system of database application technology course design
- Golang的range
- Pit & ADB wireless debugging of vivo real machine debugging
- Golang url的编码和解码
- Golang time format sorting
- Image processing 8-cnn image classification
- Use of ue5 QRcode plug-in
- [set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
猜你喜欢

Installation of PHP FPM software +openresty cache construction

php-fpm软件的安装+openresty高速缓存搭建
![[updating] wechat applet learning notes_ three](/img/05/958b8d62d3a42b38ca1a2d8631a7f8.png)
[updating] wechat applet learning notes_ three

Kwai 20200412 recruitment

CLion-Toolchains are not configured Configure Disable profile问题解决

Scite change background color

Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network

Clion toolchains are not configured configure disable profile problem solving

100 GIS practical application cases (78) - Multi compliance database design and data warehousing
![[cloud native] introduction and use of feign of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)
[cloud native] introduction and use of feign of microservices
随机推荐
Golang time format sorting
php-fpm软件的安装+openresty高速缓存搭建
[cloud native] introduction and use of feign of microservices
Storage of data
Initial unity
Basic operation and process control 2
Golang string segmentation, substitution and interception
Conversion between JSON and object
[linear table] basic operation of bidirectional linked list specify node exchange
One dimensional array two dimensional array (sort Max insert sort)
详解sizeof、strlen、指针和数组等组合题
Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
Golang中删除字符串的最后一个字符
matlab神经网络所有传递函数(激活函数)公式详解
Vscode, idea, VIM development tool shortcut keys
P1596 [USACO10OCT]Lake Counting S
Chocolate installation
Visual Studio (VS) shortcut keys
Introduction to hexadecimal coding
About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed