在unity3d中,当按下“Esc”键时,使生成的程序关闭的C#代码如何写?

2 replies [最后一篇]
ykp1988
User offline. Last seen 1 年 33 周 ago. Offline
注册用户
Joined: 04/26/2010
Points: 10

在unity3d中,当按下“Esc”键时,生成的程序关闭的C#代码如何写,我是新手不太懂,希望大虾们帮帮忙

cartoonboy
User offline. Last seen 51 周 3 天 ago. Offline
版主
Joined: 05/10/2010
Points: 316

 

using UnityEngine;
using System.Collections;

public class CLASSNAME : MonoBehaviour {
    void  Update (){
        if (Input.GetKey ("escape")) {
        Application.Quit();
        }
    }
}

uke
User offline. Last seen 3 天 7 小时 ago. Offline
超级管理员
Joined: 09/07/2009
Points: 2499

可参考js代码:

function Update () {
if (Input.GetKey ("escape")) {
Application.Quit();
}
}

转换为c#代码即可!