当前位置:网站首页>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");
}
}
}
}
边栏推荐
- [K & R] Chinese Second Edition personal questions Chapter1
- Advanced OSG collision detection
- What does (+) in Oracle mean
- Swagger document configuration
- VIM learning notes from introduction to silk skating
- Transmit pictures with Base64 encoding
- MXone Pro自适应2.0影视模板西瓜视频主题苹果cmsV10模板
- Three characteristics
- Osgearth topographic shading map drawing
- the installer has encountered an unexpected error installing this package
猜你喜欢

Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation

Minimap plug-in

Redis data structure

Simple demo of solving BP neural network by gradient descent method

matlab神经网络所有传递函数(激活函数)公式详解

Display terrain database on osgearth ball

十六进制编码简介

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
![[cloud native] introduction and use of feign of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)
[cloud native] introduction and use of feign of microservices

jupyter远程服务器配置以及服务器开机自启
随机推荐
Chocolate installation
C语言-入门-精华版-带你走进编程(一)
Creation and content of mapnode -- osgearth rendering engine series (2)
CLion-Toolchains are not configured Configure Disable profile问题解决
Golang的range
php-fpm软件的安装+openresty高速缓存搭建
图像处理8-CNN图像分类
Easy touch plug-in
Dotween plug-in
Display terrain database on osgearth ball
简易入手《SOM神经网络》的本质与原理
[updating] wechat applet learning notes_ three
Get to know unity2 for the first time
String class
LinkList
100 GIS practical application cases (78) - Multi compliance database design and data warehousing
animation
Visual Studio (VS) shortcut keys
swagger文档配置
Initial unity