UnityEditor Windows Event(3)
来源:互联网 发布:fifa online4数据库 编辑:程序博客网 时间:2024/06/08 05:36
1.自定义窗口点击Window/MyCustom下的菜单栏
using UnityEditor;using UnityEngine;public class CustomEditors : EditorWindow { public static CustomEditors instance; private string search = string.Empty; private Vector2 scrollPos; private Rect my = new Rect(100,50,100,40); [MenuItem("Window/MyCustom")] public static void Init() { EditorWindow.GetWindow<CustomEditors>(); } private void OnGUI() { if (instance == null) { instance = this; } DrapPlane(); GUILayout.BeginArea(new Rect(0, GraphConfig.Top_INDENT, position.width, position.height - GraphConfig.Top_INDENT), ""); { GUILayout.Box("YSL1111", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) }); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height)); GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(position.height) }); BeginWindows(); my = GUI.Window(1, my, ViewRender.Render, "YSL"); //EditorCurveDrawing.bezierLine(new Vector2(100, 1) ,Vector2.one, new Vector2(300,1) , new Vector2(1.67f,-1), Color.yellow, 5.0f, true,5.0f); EndWindows(); EditorGUILayout.EndScrollView(); } GUILayout.EndArea(); } private void DrapPlane() { GUIStyle myPlane = new GUIStyle(EditorStyles.label); myPlane.fontSize = 15; if (position.width > 735f) { GUILayout.BeginArea(new Rect(10, 9, 70, 30), ""); { GUILayout.Label("Search: ", myPlane); GUILayout.Label("",myPlane); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(80, 11, 150, 30), ""); { GUIStyle s = new GUIStyle(EditorStyles.textField); s.fontSize = 13; s.padding.top = 2; search = EditorGUILayout.TextField("", search, s, new GUILayoutOption[] { GUILayout.Width(120), GUILayout.Height(20) }); } GUILayout.EndArea(); } else { search = string.Empty; } float x = 460; GUILayout.BeginArea(new Rect(position.width - x - 70, 9, 70, 30), ""); { GUILayout.Label("Collaps",myPlane); GUILayout.Label("",myPlane); }GUILayout.EndArea(); string[] Option = new string[3]; Option[0] = "Nothing"; Option[1] = "Only Listern"; Option[2] = "All Matcher"; GUIStyle optionStyle = new GUIStyle(EditorStyles.popup); optionStyle.padding = new RectOffset(-10,0,-1,0); optionStyle.fixedHeight = 20; optionStyle.alignment = TextAnchor.MiddleCenter; optionStyle.fontSize = 10; OptionType.CurrentOption = EditorGUI.Popup( new Rect(position.width - x , 10 , 100 ,20 ),OptionType.CurrentOption,Option,optionStyle); }}
- 渲染处理事件信息
using UnityEngine;using UnityEditor;public class ViewRender { public static void Render(int viewId) { BaseNode y = new BaseNode(); ProcessInput(y); GUI.DragWindow(new Rect(0,0,1000,10000)); } /// <summary> /// 回调 /// </summary> /// <param name="_data"></param> private static void MenuCallBacks(object _data) { bool success; ContextMenuItem m_item = _data as ContextMenuItem; m_item.node.name = "YSL"; //m_item.node.gameObject = GameObject.Find("Cube") as GameObject ; switch (m_item.type) { case EventGraphContextMenu.OPEN_IN_EDITOR: success = EventGraphAction.OpenInEditor(m_item.node.name); if(!success) { CustomEditors.instance.ShowNotification(new GUIContent("Class Not Found")); } break; case EventGraphContextMenu.SHOW_IN_HIERARCHY: success = EventGraphAction.selectInHierarchy(m_item.node); if (!success) { CustomEditors.instance.ShowNotification(new GUIContent("Class Not Found")); } break; case EventGraphContextMenu.SELECT_EVENT_TREE: break; } EventGraphAction.OpenInEditor("YSL"); } public static void ProcessInput(BaseNode name ) { if (Event.current.button == 1 && (Event.current.type == EventType.MouseDown)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Open In Editor"),false,MenuCallBacks,new ContextMenuItem(name, EventGraphContextMenu.OPEN_IN_EDITOR)) ; menu.AddItem(new GUIContent("Show In Hierarcy"),false ,MenuCallBacks , new ContextMenuItem(name ,EventGraphContextMenu.SHOW_IN_HIERARCHY)); menu.AddItem(new GUIContent("SelectEditor"),false,MenuCallBacks,new ContextMenuItem(name,EventGraphContextMenu.SELECT_EVENT_TREE)); menu.ShowAsContext(); } }}
0 0
- UnityEditor Windows Event(3)
- UnityEditor Window Event
- UnityEditor 热键
- 初涉UnityEditor
- UnityEditor(1)
- windows service event log
- Windows Event Viewer understanding
- Event — Windows API
- windows event logs分析
- windows的event对象
- windows.event对象介绍
- Windows多线程编程(3)同步对象——Event对象
- Syslog化Windows Event日志
- keyboard event and Windows Msg
- windows 的鼠标事件(Event)
- windows 的鼠标事件(Event)
- windows 的鼠标事件(Event)
- windows.event对象详细介绍
- 非root用户离线安装python的第三方库
- css-响应Web设计1
- MySQL增删改查以及表的创建与删除
- frameset标签设计页面
- 欢迎使用CSDN-markdown编辑器
- UnityEditor Windows Event(3)
- quantization product for nearest search
- Spark分析之Standalone运行过程分析
- java编程思想读书笔记-第七章 多态
- 最近的一些问题
- UVa 12541
- Git的使用
- windows下生成pyc文件
- 启动qemu-kvm 出现errors