Version: 2017.3
public static bool enabled ;

描述

是否启用了 GUI?

将该值设置为 false 可禁用所有 GUI 交互。所有控件都将绘制为半透明状态,并且不响应用户输入。

\ 启用/禁用的 GUI 控件。

using UnityEngine;
using System.Collections;

public class ExampleClass : 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"); } }