【Unity】编辑器中实现可拖动窗口
2018-01-23 00:13
369 查看
不得不吐槽CSDN的编辑器不好用 ,学习中
参考国外大牛的文章写得可拖动小窗口 , 还是不错滴
using UnityEngine;
using UnityEditor;
public class NodeEditor : EditorWindow
{
Rect window1;
Rect window2;
[MenuItem("Window/Node editor")]
static void ShowEditor()
{
NodeEditor editor = EditorWindow.GetWindow<NodeEditor>();
editor.Init();
}
public void Init()
{
window1 = new Rect(10, 10, 100, 100);
window2 = new Rect(210, 210, 100, 100);
}
void OnGUI()
{
DrawNodeCurve(window1, window2);
BeginWindows();
window1 = GUI.Window(1, window1, DrawNodeWindow, "Window 1");
window2 = GUI.Window(2, window2, DrawNodeWindow, "Window 2");
EndWindows();
}
void DrawNodeWindow(int id)
{
GUI.DragWindow();
}
void DrawNodeCurve(Rect start, Rect end)
{
Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0);
Vector3 startTan = startPos + Vector3.right * 50;
Vector3 endTan = endPos + Vector3.left * 50;
Color shadowCol = new Color(0, 0, 0, 0.06f);
for (int i = 0; i < 3; i++) // Draw a shadow
Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
}
}
参考国外大牛的文章写得可拖动小窗口 , 还是不错滴
using UnityEngine;
using UnityEditor;
public class NodeEditor : EditorWindow
{
Rect window1;
Rect window2;
[MenuItem("Window/Node editor")]
static void ShowEditor()
{
NodeEditor editor = EditorWindow.GetWindow<NodeEditor>();
editor.Init();
}
public void Init()
{
window1 = new Rect(10, 10, 100, 100);
window2 = new Rect(210, 210, 100, 100);
}
void OnGUI()
{
DrawNodeCurve(window1, window2);
BeginWindows();
window1 = GUI.Window(1, window1, DrawNodeWindow, "Window 1");
window2 = GUI.Window(2, window2, DrawNodeWindow, "Window 2");
EndWindows();
}
void DrawNodeWindow(int id)
{
GUI.DragWindow();
}
void DrawNodeCurve(Rect start, Rect end)
{
Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0);
Vector3 startTan = startPos + Vector3.right * 50;
Vector3 endTan = endPos + Vector3.left * 50;
Color shadowCol = new Color(0, 0, 0, 0.06f);
for (int i = 0; i < 3; i++) // Draw a shadow
Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
}
}
相关文章推荐
- 【Unity】编辑器中实现类似动画编辑器中的可拖动窗口
- canvas实现拖动页面时显示窗口视频
- Windows Mobile上实现可拖动的窗口
- wpf如何实现自定义窗口自由拖动
- 可拖动窗口的JS实现
- javascript实现可拖动变色并关闭层窗口实例
- Unity之编辑器类将摄像机视图(targetTexture)绘制在窗口中
- 【.Net】 实现窗口拖动
- js仿百度登录页实现拖动窗口效果
- unity 3d中简单巧妙的实现拖动鼠标旋转物体
- [MFC] 无边框窗口的Resize拖动效果的实现(下):子窗口覆盖,导致主窗口热点区无法响应WM_NCHITTEST
- 实现用鼠标拖动没有标题栏的窗口(窗体的任何部分都可实现拖动效果)
- C#实现Winform鼠标拖动窗口大小时设定窗口最小尺寸的方法
- 【Unity优化】如何实现Unity编辑器中的协程
- 实现自己可以拖动的窗口标题
- Qt中无标题窗口实现拖动效果(Windows平台)
- 实现拖动对话框窗口移动
- 实现无边框时拖动窗口
- 使用VC实现可拖动窗口
- c#实现无标题栏窗口的拖动