Unity3D用户提示退出Android游戏

我有一个代码退出Unity3D上的退格键,
但我想给用户一个是/否问题,他真的想要退出

像这样 :

无论如何在Unity3D中执行此操作?
提前致谢

解决方法:

你可以用unity的gui将它附加到一个游戏对象,它应该这样做
你应该制作一个GUI皮肤并使用组件,你可以根据你的规格添加和调整组件

#pragma strict
var count : int = 0;
var skin : GUISkin;
function Update () {
if (Input.GetKeyDown(KeyCode.Escape)) { 
    Time.timeScale = 0;
    count = 1;
            }
}
function OnApplicationPause(){
Time.timeScale = 0;
count = 1;

}

function OnGUI(){
if(count == 1){
GUI.skin = skin;


   GUI.Box(new Rect(0,0,Screen.width,Screen.height),"Exit");
   GUI.Label(new Rect(Screen.width*1/4,Screen.height*2/6,Screen.width*2/4,Screen.height*1/6), "Are you sure you want to exit the game?");
if(GUI.Button(Rect(Screen.width/4,Screen.height*3/8,Screen.width/2,Screen.height/8),"Yes"))
          {

         Application.Quit();

          }
          if(GUI.Button(Rect(Screen.width/4,Screen.height*4/8,Screen.width/2,Screen.height/8),"Keep Playing"))
          {
          count = 0;
          Time.timeScale = 1;
}}}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐