纳金网
标题:
移动窗体 模态窗体
[打印本页]
作者:
她。
时间:
2012-11-3 10:49
标题:
移动窗体 模态窗体
移动窗体
//設定拖曳視窗大小
var windowRect : Rect = Rect (20, 20, 120, 50);
//限制可移動範圍
var constrain : Rect;
//滑鼠座標
private var e : Event;
function OnGUI () {
//取得滑鼠座標
e = Event.current;
//顯示範圍用,可有可無
GUI.Box(constrain, "Drag Here");
windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
}
function DoMyWindow (windowID : int) {
//限制可移動範圍
if(e.mousePosition.x > constrain.x && e.mousePosition.x < (constrain.width + constrain.x) && e.mousePosition.y > constrain.y && e.mousePosition.y < (constrain.height + constrain.y)){
GUI.DragWindow (Rect (0,0, 10000, 20));
}
}
模态窗口
// Draws 2 overlapped windows and when clicked on 1 window's button
// Brings the other window to the front.
private var windowRect : = [url=]Rect (20, 20, 120, 50);
private var windowRect2 : = [url=]Rect (80, 20, 120, 50);
function OnGUI () {
windowRect = [url=]GUI.Window[/url] (0, windowRect, DoMyFirstWindow, "First");
windowRect2 = [url=]GUI.Window[/url] (1, windowRect2, DoMySecondWindow, "Second" );
}
function DoMyFirstWindow (windowID : int) {
if ( ([url=]Rect (10,20,100,20), "Bring to front"))
[url=]GUI.BringWindowToFront[/url](1); //Bring the 2nd window to front
([url=]Rect (0,0, 10000, 20));
}
function DoMySecondWindow (windowID : int) {
if ( ([url=]Rect (10,20,100,20), "Bring to front"))
[url=]GUI.BringWindowToFront[/url](0); //Bring the 1rst window to front
([url=]Rect (0,0, 10000, 20));
}
作者:
王者再临
时间:
2012-11-4 13:23
学习学习了。支持
作者:
艾西格亚
时间:
2012-11-4 23:29
感谢分享
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5