unity场景切换、截屏、打开网址、退出应用程序

来源:互联网 发布:js埋点代码收集脚本 编辑:程序博客网 时间:2024/06/11 23:20

//注意:做加载场景操作前一定要先做如下操作,File->Bulid Settings 把需要打包的场景都拉进去,然后关闭即可


using UnityEngine;

using System.Collections;


public class ApplicationControl : MonoBehaviour {


// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
      if(Input.GetKeyDown(KeyCode.A)){ //按下A键,加载A场景
          Application.LoadLevel("A");
      }
      if(Input.GetKeyDown(KeyCode.B)){//按下B键,加载B场景
          Application.LoadLevel("B");
      }
      if(Input.GetKeyDown(KeyCode.C)){//按下C键,加载c场景
          Application.LoadLevel("C");
      }
      if(Input.GetKeyDown(KeyCode.Space)){
          Application.CaptureScreenshot(@"C:\Users\zxy\Desktop\1.png");//按下空格键,截屏,参数为保存的位置
      }
      if(Input.GetKeyDown(KeyCode.D)){
          Application.OpenURL("www.baidu.com");//打开一个网址
      }
      if(Input.GetKeyDown(KeyCode.Escape)){
          Application.Quit();//退出应用程序
      }
}
}