说明:为了实现场景A->大场景B,可以让场景A->等待场景C->大场景B
知识点:AsyncOperation;AsyncOperation.allowSceneActivation;SceneManager.LoadSceneAsync("sceneName");
操作:
1.定义个全局变量 static string TargetScene="";
2.A中:DataStore.TargetScene="大场景B";
SceneManager.LoadScene("等待场景C");
3.C中:
AsyncOperation operation;
void start(){
StartCoroutine(LoadRealScene());
}
IEnumerator LoadRealScene(){
operation=SceneManager.LoadSceneAsync(DataStore.TargetScene);
operation.allowSceneActivation=false;//禁用场景加载完自切
yield return operation;
}
void Update(){
if(operation.process==1.0f){
operation.allowSceneActivation=true;//异步操作进度完成后,将目标场景激活
}
}