zoukankan      html  css  js  c++  java
  • Application类

    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:UsersludsDesktop			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
    		}
    	}
    }
        
    

      

  • 相关阅读:
    [滤镜]的firefox兼容问题
    软件编程中的21条法则
    程序员!你应该读别人的心得,但是一定要自己注解
    致橡树——舒婷
    高级动物
    终于把网站最后一个模块了结了
    终于解决了网站程序中的问题
    北京杂种
    博客园驻小窝
    Eval函数
  • 原文地址:https://www.cnblogs.com/xingyunge/p/6814661.html
Copyright © 2011-2022 走看看