GUI
- 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.enabled 是否启用?
static var enabled : bool
Description描述
Is the GUI enabled?
Set this value to false to disable all GUI interaction. All controls will be draw semi-transparently, and will not respond to user input.
判断GUI是否启用了。
设置为false禁用所用GUI互动,所有控件将被绘制半透明,并且将不响应用户输入。
Enabled / Disabled GUI controls.
启用禁用GUI控件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public bool allOptions = true;
public bool extended1 = true;
public bool extended2 = true;
void OnGUI() {
allOptions = GUI.Toggle(new Rect(0, 0, 150, 20), allOptions, "Edit All Options");
GUI.enabled = allOptions;
extended1 = GUI.Toggle(new Rect(20, 20, 130, 20), extended1, "Extended Option 1");
extended2 = GUI.Toggle(new Rect(20, 40, 130, 20), extended2, "Extended Option 2");
GUI.enabled = true;
if (GUI.Button(new Rect(0, 60, 150, 20), "Ok"))
print("user clicked ok");
}
}
//该值跟踪扩展选项是否被禁用。
var allOptions : boolean = true;
//2个扩展选项的开关
var extended1 : boolean = true;
var extended2 : boolean = true;
function OnGUI () {
//创建一个开关,用于控制下面GUI元素是否可编辑
allOptions = GUI.Toggle (Rect (0,0,150,20), allOptions, "Edit All Options");
//GUI元素的互动开关,禁用的话所有元素将变为变透明
GUI.enabled = allOptions;
// These two controls will only be enabled if the button above is on.
extended1 = GUI.Toggle (Rect (20,20,130,20), extended1, "Extended Option 1");
extended2 = GUI.Toggle (Rect (20,40,130,20), extended2, "Extended Option 2");
// 这里我们打开GUI元素的互动,下面的元素将可以被操作
GUI.enabled = true;
// 创建一个按钮,这个按钮将不会被禁用
if (GUI.Button (Rect (0, 60, 150, 20), "Ok"))
print ("user clicked ok");
}
最后修改:2011年6月15日 Wednesday 10:51