场景&&场景切换
一个scene就是一个场景(关卡),打开file->build Settings,将场景添加到scenes in build中,拖拽排序,第一个场景为游戏启动的默认场景,
多个场景之间切换代码如下
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LoadScreen : MonoBehaviour
{
    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勾上
                                                    
