当前位置:网站首页>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");
}
}
}
}
边栏推荐
- UE4 call DLL
- swagger文档配置
- Shader foundation 01
- Minimap plug-in
- Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
- Delete the last character of the string in golang
- Luaframwrok handles resource updates
- Exe file running window embedding QT window
- UE4 source code reading_ Bone model and animation system_ Animation node
- Kwai 20200412 recruitment
猜你喜欢
[updating] wechat applet learning notes_ three
matlab神经网络所有传递函数(激活函数)公式详解
十六进制编码简介
Dotween plug-in
Oracle insert single quotation mark
Advanced OSG collision detection
Haproxy+kept build 01
UE4 source code reading_ Bone model and animation system_ Animation process
Gradle's method of dynamically modifying APK package name
Three characteristics
随机推荐
Base64和Base64URL
Golang 中string和int类型相互转换
Ue5 opencv plug-in use
P1896 [scoi2005] non aggression (shape pressure DP)
Student educational administration management system of C # curriculum design
基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
Osgearth target selection
Intersectionpicker in osgearth
Storage of data
Shader foundation 01
Data analysis exercises
Abstract classes and interfaces
the installer has encountered an unexpected error installing this package
[updating] wechat applet learning notes_ three
Map的实现类的顺序性
Classes and objects
【K&R】中文第二版 个人题解 Chapter1
Pit & ADB wireless debugging of vivo real machine debugging
Xlua task list youyou
P2622 light off problem II (state compression search)