SpringDragon

导航

 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using System.IO;
using UnityEngine.SceneManagement;

public class Scripts : MonoBehaviour {

	// Use this for initialization
	void Start () {
		// Application 应用程序

		// 设置应用程序能否后台运行(更强调的是在手机端),是一个访问器
		// Application.runInBackground = true;

		// 获取当前项目中的资源文件夹(Assets)路径
		// 例如:需要获取资源文件夹中音频,视频,图片。。。
		// C:\Users\luds\Desktop			Windows--Dos
		// /Users/luds/Desktop				Mac/Linux/Unix/...
                
		string path = Application.dataPath;
		Debug.Log (path);

		// 应用程序的工作路径
		// 我们需要将程序中的某些内容进行持久化存储
		string path2 = Application.persistentDataPath;
		Debug.Log (path2);
	}

	void Update() {
		if (Input.GetKeyDown (KeyCode.Space)) {
			string path = "/Users/luds/Desktop/";
			string realPath = path + "screenshot" + ".png";
			// 判断某个文件是否存在
			if (File.Exists (realPath)) {

				int startIndex = 1;

				while (true) {
					realPath = path + "screenshot(" + (startIndex++) + ").png";

					if (!File.Exists (realPath)) {
						break;
					}
				}
			}
			// 获取屏幕截图;参数为保存的路径
			Application.CaptureScreenshot(realPath);
		}
		if (Input.GetKeyDown (KeyCode.Mouse0)) {
			// 在浏览器中打开一个链接
			// URL: 统一资源定位符
			// 协议://主机:端口/访问的文件路径?参数=参数值&参数=参数值
			Application.OpenURL ("http://www.baidu.com");
		}
		if (Input.GetKeyDown (KeyCode.Escape)) {
			// 退出应用程序
			Application.Quit();
		}
		if (Input.GetKeyDown (KeyCode.Tab)) {
			// 切换场景到Scence1
			// using UnityEngine.SceneManagement;
			SceneManager.LoadScene("Scence1");
			// 切换场景的时候一定要保证两个场景都被编译了
			// 在 File - BuildSettinds - Add Open Scence
		}
	}
}
    

  

posted on 2017-05-05 19:39  chenquanlong  阅读(276)  评论(0编辑  收藏  举报