Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.BeginGroup 开始组
# [GUI](GUI.html).BeginGroup 开始组 static function BeginGroup (position : Rect) : void static function BeginGroup (position : Rect, text : string) : void static function BeginGroup (position : Rect, image : Texture) : void static function BeginGroup (position : Rect, content : GUIContent) : void static function BeginGroup (position : Rect, style : GUIStyle) : void static function BeginGroup (position : Rect, text : string, style : GUIStyle) : void static function BeginGroup (position : Rect, image : Texture, style : GUIStyle) : void static function BeginGroup (position : Rect, content : GUIContent, style : GUIStyle) : void ### Parameters**参数** * *position* Rectangle on the screen to use for the group. 用于组在屏幕上矩形的位置 * *text* Text to display on the group. 在组上显示的文本 * *image* Texture to display on the group. 在组上显示的纹理图片 * *content* Text, image and tooltip for this group. If supplied, any mouse clicks are "captured" by the group and not If left out, no background is rendered, and mouse clicks are passed 用于组的文本,图片和提示,如果提供,任意鼠标点击被组捕获,如果不提供,不会渲染背景和传递鼠标点击。 * *style* The style to use for the background. 用于背景的样式。 *Description* 描述 Begin a group. Must be matched with a call to [EndGroup](GUI.EndGroup.html). 开始组,必须配套以 [EndGroup](GUI.EndGroup.html) 结束关闭容器。 When you begin a group, the coordinate system for GUI controls are set so (0,0) is the top-left corner of the group. All controls are clipped to the group. Groups can be nested - if they are, children are clipped to their parents. 当你开始创建一个组,里面的 GUI 控件的坐标系统相对于组的左上角设置为 0,0,所有的控件被限制到该组,组可以嵌套,子组将依附于父组。 This is very useful when moving a bunch of GUI elements around on screen. A common use case is designing your menus to fit on a specific screen size, then centering the GUI on larger displays. 当你在屏幕上移动一批 GUI 元素的时候,使用组将非常有用,一个常见的用例是设计你的菜单适配特殊的屏幕分辨率,然后,GUI 在大显示器上居中对齐。 另见: [matrix](GUI.matrix.html), [BeginScrollView](GUI.BeginScrollView.html). * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void OnGUI() { GUI.BeginGroup(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 600)); GUI.Box(new Rect(0, 0, 800, 600), "This box is now centered! - here you would put your main menu"); GUI.EndGroup(); } } ``` ``` function OnGUI () { //在屏幕上约束所有元件在800x600像素的区域内。 GUI.BeginGroup(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 600)); //绘制一个box,注意坐标是基于BeginGroup的 GUI.Box(new Rect(0,0,800,600), "This box is now centered! - here you would put your main menu"); //这个组是成对出现的,所以需要EndGroup来结束这个容器。 GUI.EndGroup(); } ```
da
2022年5月23日 13:40
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码