Loading Screen with SceneManager.LoadSceneAsync
Unity 5.6.0f3
void Start(){ //StartCoroutine(LoadingScreenEnum()); If I use this it ignores async.allowSceneActivation = false //button.onClick.Invoke(); this also ignores async.allowSceneActivation
}
public void LoadingScreenMeth(){
StartCoroutine(LoadingScreenEnum());
//using this from a button works and takes into consideration async.allowSceneActivation = false
}
IEnumerator LoadingScreenEnum(){
loadingScreenOb.SetActive (true);
async = SceneManager.LoadSceneAsync ("Menu");
async.allowSceneActivation = false;
while (async.isDone == false) {
progressBar.value = async.progress;
float textProgress = async.progress * 100;
loadText.text = "Loading " + Mathf.Round(testProgress) + "%...";
if (async.progress == 0.9f) {
loadText.text = "Loading 100%...";
// async.allowSceneActivation = true;
// progressBar.value = 1f;
}
yield return null;
}
}
My question is why is async.allowSceneActivation get ignored when I don't use it from a button by physically clicking it? I have tried calling button OnClick.Invoke but that ignores it as well and the level loads directly as soon as it is done. Even with the line setting allowSceneActivation to = true commented out or removed it still goes straight to the game.
I want to be able to have this code called on Start, as soon as the Powered by Unity Screen is gone I want this to show, and while that works I just can't get the loading screen to not directly go into the game.