Unity 编辑器扩展自定义窗体
2015-02-11 22:26
429 查看
这次看见Unity还可以自定义弹出窗体,让我很好奇.于是就去网上找文章看了看. 如果想自定义窗体需要把类放入Editor文件夹下面.
代码如下:
1. 暂时没有找到自定义窗体和组件之间是如何传递值的!
本文固定链接: http://www.xuanyusong.com/archives/2211
转载请注明: 雨松MOMO 2013年04月15日 于 雨松MOMO程序研究院 发表
代码如下:
using UnityEngine; using UnityEditor; public class MyEditor : EditorWindow { [MenuItem("GameObject/window")] static void AddWindow() { Rect wr = new Rect(0, 0, 500, 500); MyEditor window = (MyEditor)EditorWindow.GetWindowWithRect(typeof(MyEditor), wr, true, "盘子脸"); } private string text; private Texture texture; public void Awake() { texture = Resources.Load("1") as Texture; } void OnGUI() { text = EditorGUILayout.TextField("输入文字", text); if (GUILayout.Button("打开通知", GUILayout.Width(200))) { this.ShowNotification(new GUIContent("This is a Notification")); } if (GUILayout.Button("关闭通知", GUILayout.Width(200))) { //关闭通知栏 this.RemoveNotification(); } EditorGUILayout.LabelField("鼠标在窗口的位置", Event.current.mousePosition.ToString()); texture = EditorGUILayout.ObjectField("添加贴图", texture, typeof(Texture), true) as Texture; if (GUILayout.Button("关闭窗口", GUILayout.Width(200))) { //关闭窗口 this.Close(); } } void OnFocus() { Debug.Log("当窗口获得焦点调用一次"); } void OnLostFocus() { Debug.Log("当窗口丢失焦点调用一次"); } void OnHierarchyChange() { Debug.Log("当Hierarchy视图中的任何对象发生改变时调用一次"); } void OnProjectChange() { Debug.Log("当Project视图中的资源发生改变时调用一次"); } void OnInspectorUpdate() { this.Repaint(); } void OnSelectionChange() { foreach (Transform t in Selection.transforms) { Debug.Log("OnSelectionChange" + t.name); } } void OnDestroy() { Debug.Log("当窗口关闭时候调用"); } }
1. 暂时没有找到自定义窗体和组件之间是如何传递值的!
本文固定链接: http://www.xuanyusong.com/archives/2211
转载请注明: 雨松MOMO 2013年04月15日 于 雨松MOMO程序研究院 发表
相关文章推荐
- Unity Editor 编辑器扩展 十三 自定义创建资源
- unity 扩展编辑器二 新建窗体
- OpenCms自定义结构化类型的高级设置——扩展OpenCmsHtml类型的编辑器
- 自定义Unity 容器的扩展 --- Unity Application Block Event Broker
- Unity 扩展属性自定义绘制
- Unity扩展编辑器--类型3:Custom Editors
- Unity扩展编辑器--类型1:Editor Windows
- 【MSDN文摘】使用自定义验证组件库扩展 Windows 窗体: Form Scope
- unity编辑器扩展
- Unity3d UnityEditor EditorWindow 自定义窗体控件
- Unity Editor Toolbar 编辑器扩展
- 【unity】拓展自定义编辑器窗口(二)
- Spring功能扩展的一些思考——Spring自定义属性编辑器为例
- 使用自定义验证组件库扩展 Windows 窗体,第 2 部分(Windows 窗体探索)
- Unity编辑器扩展Texture显示选择框
- 自定义Unity 容器的扩展 --- Unity Application Block Event Broker
- 使用自定义验证组件库扩展 Windows 窗体
- Unity 自定义编辑窗体之ScriptableWizard
- [Unity编辑器]自定义编辑器界面
- Unity自定义窗体插件工具