Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.depth 深度
# [GUI](GUI.html).depth 深度 static var *depth* : int *Description* 描述 The sorting depth of the currently executing GUI behaviour. 当前执行的 GUI 行为的深度排序。 Set this to determine ordering when you have different scripts running simultaneously. 当你有不同的脚本同时运行,设置这个值来确定排序。 **Note:** To see this example working, you will need to create 2 scripts. Remember to name the scripts with the same name as the class names, else it will not work. 注意:下面的例子,接下来创建 2 个脚本文件,记得文件名和类名一样,否则将无法正常运行。  One Button behind the other. 一个按钮在另一个后面。 这个文件名为 example1 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example1 : MonoBehaviour { public static int guiDepth = 0; void OnGUI() { GUI.depth = typeof(guiDepth); if (GUI.RepeatButton(new Rect(0, 0, 100, 100), "GoBack")) { typeof(guiDepth) = 1; example2.guiDepth = 0; } } } public class example : MonoBehaviour { } ``` ``` // Makes this button go back in depth over the example2 class one. class example1 extends MonoBehaviour { static var guiDepth : int = 0; function OnGUI() { GUI.depth = guiDepth; if(GUI.RepeatButton(Rect(0,0,100,100), "GoBack")) { guiDepth = 1; example2.guiDepth = 0; } } } ``` 这个文件名为 example2 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example2 : MonoBehaviour { public static int guiDepth = 1; void OnGUI() { GUI.depth = typeof(guiDepth); if (GUI.RepeatButton(new Rect(50, 50, 100, 100), "GoBack")) { typeof(guiDepth) = 1; example1.guiDepth = 0; } } } public class example : MonoBehaviour { } ``` ``` // Makes this button go back in depth over the example1 class one. class example2 extends MonoBehaviour { static var guiDepth : int = 1; function OnGUI() { GUI.depth = guiDepth; if(GUI.RepeatButton(Rect(50,50,100,100), "GoBack")) { guiDepth = 1; example1.guiDepth = 0; } } } ```
da
2022年5月23日 13:44
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码