Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.DragWindow 拖动窗口
# [GUI](GUI.html).DragWindow 拖动窗口 static function *DragWindow* (*position* : [Rect](../Rect/Rect.html)) : void ### Parameters**参数** * *position* the part of the window that can be dragged. This is clipped to the actual window. 能拖动窗口部分的位置,这是被修剪到实际窗口。 *Returns* [Rect](../Rect/Rect.html) - the rectangle the window is at. 返回 Rect 类型,窗口所在的矩形。 *Description* 描述 Make a window draggable. 创建一个可拖动窗口。 Insert a call to this function inside your window code to make a window draggable. 在你的窗口代码,插入调用到这个函数,来创建一个可拖动窗口。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Rect windowRect = new Rect(20, 20, 120, 50); void OnGUI() { windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window"); } void DoMyWindow(int windowID) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); } } ``` ``` var windowRect : Rect = Rect (20, 20, 120, 50); function OnGUI () { //注册一个窗口 windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window"); } //创建窗口内容 function DoMyWindow (windowID : int) { //创建一个10000x20像素很长的矩形 //这样做可以你调整窗口大小而不用在修改这个值,20就是标题栏的高度,这个范围是可以拖动的 GUI.DragWindow (Rect (0,0, 10000, 20)); } ``` • static function *DragWindow* () : void *Description* 描述 If you want to have the entire window background to act as a drag area, use the version of DragWindow that takes no parameters and put it at the end of the window function. 如果你想将完整的窗口背景作为拖动区域,使用 DragWindow 不带参数的版本,放在窗口函数的末尾。 This will mean that any other controls will get precedence and the dragging will only be activated if nothing else has mouse focus. 这将意味着,任何其他控件将会得到优先,拖动将仅在如果没有别的鼠标焦点被激活。 另见: [DragWindow](GUI.DragWindow.html), [BringWindowToFront](GUI.BringWindowToFront.html), [BringWindowToBack](GUI.BringWindowToBack.html) * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Rect windowRect = new Rect(20, 20, 120, 50); void OnGUI() { windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window"); } void DoMyWindow(int windowID) { GUI.Button(new Rect(10, 20, 100, 20), "Can't drag me"); GUI.DragWindow(); } } ``` ``` var windowRect : Rect = Rect (20, 20, 120, 50); function OnGUI () { //注册一个窗口 windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window"); } // 制作窗口内容 function DoMyWindow (windowID : int) { GUI.Button (Rect (10,20,100,20), "Can't drag me"); // Insert a huge dragging area at the end. // This gets clipped to the window (like all other controls) so you can never drag the window from outside it. //在末尾插入一个很大的可拖动区域,这得到被修剪的窗口(像其他控件一样),因此你永远无法从外面拖动窗口。 GUI.DragWindow (); } ```
da
2022年5月23日 13:44
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码