unity3d之弹窗

来源:互联网 发布:网络异常是怎么回事 编辑:程序博客网 时间:2024/04/28 08:31

之前对GUI掌握的很差,每次在想实现结束游戏,弹窗操作时都无从下手,今天特意查了下,完成了这个功能。

即通过GUI.Window()

函数原型:

static Rect Window(int id, Rect clientRect, WindowFunction func, string text);
static Rect Window(int id, Rect clientRect, WindowFunction func, Texture image);
代码示例:
using UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour {    public bool doWindow0 = true;    void DoWindow0(int windowID) {        GUI.Button(new Rect(10, 30, 80, 20), "Click Me!");    }    void OnGUI() {                if (doWindow0)            GUI.Window(0, new Rect(110, 10, 200, 60), DoWindow0, "Basic Window");            }}
这段代码实现,弹窗操作时需要对bool变量doWindow0进行判断。

0 0
原创粉丝点击