Hi i'm going to make a loading screen between scene A and scene B. I have now used Async Operation to bring in Thin B asynchronously. But I can't do that.
I took a log, and all the screens stop until Async Operation's progress reaches 0.9 which I randomly set.
If the progress exceeds 0.9 then everything starts to work.
Why is that? Is it because the capacity of Thin B is very large?
If I can't use Async Operation, how should I make a loading screen? Please help me! I attached my code below.
IEnumerator Start()
{
yield return null;
StartCoroutine(LoadingProgress(loadSceneName));
}
IEnumerator LoadingProgress(string loadSceneName)
{
AsyncOperation async = SceneManager.LoadSceneAsync(loadSceneName);
async.allowSceneActivation = false;
float timer = 0.0f;
while (!async.isDone)
{
timer += Time.deltaTime;
if (async.progress >= 0.9f)
{
loadingBar.fillAmount = Mathf.Lerp(loadingBar.fillAmount, 1f, timer);
if (loadingBar.fillAmount == 1.0f)
{
async.allowSceneActivation = true;
yield break;
}
}
else
{
loadingBar.fillAmount = Mathf.Lerp(loadingBar.fillAmount, async.progress, timer);
if (loadingBar.fillAmount >= async.progress)
{
timer = 0f;
}
}
yield return null;
}
}