Application的常用方法:
static void LoadLevel(int index);
static void LoadLevel(string name);
static void CaptureScreenShot(string fileName);
static void OpenURL(string url);
static void Quit();
创建三个场景,分别命名为a, b, c,并在各个场景中创建GUI text文字
编写一个c# script文件,分别加到各个场景的main camera上。
脚本代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.A))
{
Application.LoadLevel(0);
}
if (Input.GetKeyDown(KeyCode.B))
{
Application.LoadLevel(1);
}
if (Input.GetKeyDown(KeyCode.C))
{
Application.LoadLevel(2);
}
if (Input.GetKeyDown(KeyCode.Space))
{
Application.CaptureScreenshot(@"D:\jodie.chen\My Documents\My Pictures\1.png");//图片文件保存目录
}
}
}
运行以后,console出现警告warning CS0618: `UnityEngine.Application.LoadLevel(int)' is obsolete: `Use SceneManager.LoadScene'
参考官方文档:scene manager: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html
等有时间了仔细研究下新的表达方式,大概是SceneManager.GetSceneByBuildIndex(int index)这样。
问题:如果连续保存截图,后面的截图会以相同的名字覆盖掉之前的截图,如何才能连续保存?