场景&&场景切换 一个scene就是一个场景(关卡),打开file->build Settings,将场景添加到scenes in build中,拖拽排序,第一个场景为游戏启动的默认场景, 多个场景之间切换代码如下 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class LoadScreen : MonoBehaviour { // 暂时还不清楚这个名字不在scenes文件夹或者在子文件夹会有什么影响 public string SceneName = "SampleScene"; // 延迟时间 public float Delay = 5f; void Start() { // 5秒后自动切换场景 StartCoroutine(ChangeSceneAfterDelay(Delay)); } // 切换场景 private IEnumerator ChangeSceneAfterDelay(float delay) { // 等待delay秒 yield return new WaitForSeconds(delay); // 切换场景 UnityEngine.SceneManagement.SceneManager.LoadScene(SceneName); } void Update() { } } 后台运行 默认情况下,游戏到后台后就停止运行了,要设置在后台运行 菜单Edit->Project Settings->Player,右边的Resolution and Presentation选项卡中将Run In Background勾上