转载地址:http://bbs.9ria.com/thread-260579-1-1.html
添加一个弹出的窗口,用来给用户选择退出还是不退出。
#pragma strict var customSkin : GUISkin; var OKButton : Texture2D; var cancelButton : Texture2D; private var showExitWindow : boolean = false; function Start () { } function Update () { } function OnGUI () { GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(Screen.width / 800.0, Screen.height / 600.0, 1)); GUI.skin = customSkin; if (showExitWindow) { GUI.Window(0, Rect(200, 200, 400, 200), DoMyWindow, ""); } else { if (GUI.Button(Rect(250, 225, 300, 150), "", "PlayButton")) { Application.LoadLevel(2); } if (GUI.Button(Rect(650, 450, 100, 100), "", "ExitButton")) { showExitWindow = true; } } } function DoMyWindow () { if (GUI.Button(Rect(32, 90, 100, 100), cancelButton)) { showExitWindow = false; } if (GUI.Button(Rect(267, 90, 100, 100), OKButton)) { } }