- backgroundColor
- BeginGroup
- BeginScrollView
- Box
- BringWindowToBack
- BringWindowToFront
- Button
- changed
- color
- contentColor
- depth
- DragWindow
- DrawTexture
- enabled
- EndGroup
- EndScrollView
- FocusControl
- FocusWindow
- GetNameOfFocusedControl
- GUI
- HorizontalScrollbar
- HorizontalSlider
- Label
- matrix
- PasswordField
- RepeatButton
- ScrollTo
- SelectionGrid
- SetNextControlName
- skin
- TextArea
- TextField
- Toggle
- Toolbar
- tooltip
- UnfocusWindow
- VerticalScrollbar
- VerticalSlider
- Window
GUI.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参数
- positionRectangle on the screen to use for the group.
用于组在屏幕上矩形的位置 - textText to display on the group.
在组上显示的文本 - imageTexture to display on the group.
在组上显示的纹理图片 - contentText, 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
用于组的文本,图片和提示,如果提供,任意鼠标点击被组捕获,如果不提供,不会渲染背景和传递鼠标点击。 - styleThe style to use for the background.
用于背景的样式。
Description描述
Begin a group. Must be matched with a call to EndGroup.
开始组,必须配套以EndGroup结束关闭容器。
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, BeginScrollView.
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();
}