小彬彬 发表于 2012-8-11 17:26

一个带滑条的自动布局系列按扭,点击弹出带关闭按扭的...


首先一个托动框的基本构架。

\\活动框一定要是先定义的窗口大小名称,只有实例化的窗口才可以交互拖动。

var windowRect = Rect (20, 20, 120, 50);

function OnGUI () {

\\实例化定义好的活动窗。DoMyWindow为于ID对应的GUI函数。
windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
}

//对应DoMyWindow制作窗体内容。
function DoMyWindow (windowID : int) {

//加入了一个按扭,非必要的。
GUI.Button (Rect (10,20,100,20), "Can't drag me");
// 使窗口可以托动。
GUI.DragWindow ();
}


-----------------------------------------------------------------------------------------------------------------------

以下为整体内容。


var scrollVec : Vector2;

var cls:boolean=false;
var xx = Rect (120, 120, 320, 250);
function OnGUI(){


GUI.Window(0, Rect(Screen.width-100, 35, 100, 220 ), windowF, "Management");

if(cls)

xx = GUI.Window(1, xx, windowjj, "Warehouse");



}


function windowF(){

GUILayout.BeginArea(Rect(4, 20, 90, 170));

scrollVec = GUILayout.BeginScrollView(scrollVec);

if(GUILayout.Button ("Warehouse"))

cls=true;


GUILayout.Button("Start");

GUILayout.Button("Fighting");

GUILayout.Button("Back");

GUILayout.Button("1");

GUILayout.Button("2");

GUILayout.Button("3");

GUILayout.Button("4");

GUILayout.Button("5");

GUILayout.Button("6");

GUILayout.Button("7");

GUILayout.Button("8");

GUILayout.EndScrollView();

GUILayout.EndArea();

GUI.DragWindow ();


}


function windowjj(windowID : int){

GUILayout.BeginArea(Rect(130, 160, 50, 130));


if(GUILayout.Button("Close")) cls=false;

GUILayout.EndArea();
GUI.DragWindow ();
}



chu35177 发表于 2012-12-17 15:01

看他一看..........

游卧云端 发表于 2017-2-14 20:50

很不错

airarmy 发表于 2017-2-14 20:47

顶顶多好

无聊↑国人 发表于 2017-2-14 20:16

说的非常好

gaojinjin 发表于 2017-2-14 20:43

很好哦

juncolor 发表于 2017-2-14 21:09

LZ真是人才

palehawk 发表于 2017-3-28 18:04

很不错

usbabs 发表于 2017-3-28 18:12

好帖就是要顶

raomuqi@qq.com 发表于 2017-3-28 18:24

顶顶多好
页: [1]
查看完整版本: 一个带滑条的自动布局系列按扭,点击弹出带关闭按扭的...