Application类相关api

  1. 屏幕截图,移动平台上,文件名附加到持久数据路径Application.persistentDataPath,第二个参数大于1生成更高分辨率
	ScreenCapture.CaptureScreenshot("test01.png", 0);
  1. 持久数据的路径(只读)Application.persistentDataPath
  2. 流动资产的路径(只读)Application.streamingAssetsPath
  3. 短暂的缓存路径(只读)Application.temporaryCachePath
  4. Application相关(第三行如果是编辑模式也会写清楚)
       print(Application.isEditor);
       print(Application.isPlaying);
       print(Application.platform);
  1. 日志相关
   string output = "";//日志输出信息
   string stack = "";//堆栈跟踪信息
   string logType = "";//日志类型
   int tp = 0;
   //打印日志信息
   void Update()
   {
       Debug.Log("stack:" + stack);
       Debug.Log("logType:" + logType);
       Debug.Log("tp:"+(tp++));
       Debug.Log("output:" + output);
   }
   void OnEnable()
   {
       //注册委托
      
       Application.logMessageReceived += MyCallback;
   }
   void OnDisable()
   {
       //取消委托
       Application.logMessageReceived -= MyCallback;
   }
   //委托方法
   //方法名字可以自定义,但方法的参数类型要符合Application.LogCallback中的参数类型
   void MyCallback(string logString, string stackTrace, LogType type)
   {
       output = logString;
       stack = stackTrace;
       logType = type.ToString();
   }
  1. 异步加载场景相关(待补充)

猜你喜欢

转载自blog.csdn.net/qq_37811712/article/details/85724220