GUI.Window窗口

Note: If you are using  GUILayout to place your components inside the window, you should use GUILayout.Window. Also, if MonoBehaviour.useGUILayout is set to false then a call to GUI.Window will not have any effect, even though it is not a GUILayout function.
	var windowRect : Rect = Rect (20, 20, 120, 50);

function OnGUI () { // Register the window. Notice the 3rd parameter windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window"); }

// Make the contents of the window function DoMyWindow (windowID : int) { if (GUI.Button (Rect (10,20,100,20), "Hello World")) print ("Got a click"); }
You can use the same function to create multiple windows. Just make sure that  each window has its own ID. Example:
	var windowRect0 : Rect = Rect (20, 20, 120, 50);
	var windowRect1 : Rect = Rect (20, 100, 120, 50);

function OnGUI () { // Register the window. We create two windows that use the same function // Notice that their IDs differ windowRect0 = GUI.Window (0, windowRect0, DoMyWindow, "My Window"); windowRect1 = GUI.Window (1, windowRect1, DoMyWindow, "My Window")//这里必须返回窗体的Rect,否则无法拖动窗口
	}

// Make the contents of the window function DoMyWindow (windowID : int) { if (GUI.Button (Rect (10,20,100,20), "Hello World")) print ("Got a click in window " + windowID); // Make the windows be draggable. GUI.DragWindow (Rect (0,0,10000,10000));//拖动窗口的代码,必须要是10000吗,反正1000不可以拖动 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值