unity3d之弹窗

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

即通过GUI.Window()

函数原型:

static  Rect  Window(int  idRect  clientRect, WindowFunction  func, string  text);
static  Rect  Window(int  idRect  clientRect, WindowFunction  funcTexture  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进行判断。

猜你喜欢

转载自blog.csdn.net/feizxiang3/article/details/37169141