异步加载场景,SceneManager.LoadSceneAsync(SceneName);需引用 using UnityEngine.SceneManagement;命名空间,
Application.LoadLevel这个方法不再适用;
可以用协同程序做一个简单的计时器,详见代码;
DontDestroyOnLoad (this.gameObject);方法可以在加载场景时不销毁指定物体;
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using UnityEngine.SceneManagement; 5 6 public class Base : MonoBehaviour { 7 8 public virtual void ScenesLoad(string SceneName,int AfterSomeMinutesToLoad) 9 { 10 StartCoroutine (Calculagraph(SceneName,AfterSomeMinutesToLoad)); 11 } 12 IEnumerator Calculagraph(string SceneName,int AfterSomeMinutesToLoad) 13 { 14 yield return new WaitForSeconds (AfterSomeMinutesToLoad*60); 15 DontDestroyOnLoad (this.gameObject); 16 SceneManager.LoadSceneAsync(SceneName); 17 } 18 }