AsyncOperation.progress由0直接到0.9,当时进度条加载结束时却不能立刻进入场景,有大神知道怎么破吗?
private IEnumerator StartLoading(int scene, float deltaTime) {
yield return new WaitForSeconds ( deltaTime );
int displayProgress = 0;
int toProgress = 0;
AsyncOperation op = Application.LoadLevelAsync(scene);
op.allowSceneActivation = false;
while(op.progress < 0.9f) {
toProgress = (int)op.progress * 100;
while(displayProgress < toProgress) {
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();
}
}
toProgress = 100;
while(displayProgress < toProgress){
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();
}
op.allowSceneActivation = true;
}
private IEnumerator StartLoading(int scene, float deltaTime) {
yield return new WaitForSeconds ( deltaTime );
int displayProgress = 0;
int toProgress = 0;
AsyncOperation op = Application.LoadLevelAsync(scene);
op.allowSceneActivation = false;
while(op.progress < 0.9f) {
toProgress = (int)op.progress * 100;
while(displayProgress < toProgress) {
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();
}
}
toProgress = 100;
while(displayProgress < toProgress){
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();
}
op.allowSceneActivation = true;
}