Load Scene Unity by Application.LoadLevelAsync
I use the function Application.LoadLevelAsync (s); in the game but it just stops at 89%. I have read some posts on the forum but did not solve the problem. Help me fix that. my code below:
public void LoadScenes (string s)
{
if (!quit) {
SoundController.PlaySound (soundGame.ButtomClick);
progressBars.gameObject.SetActive (true);
background.SetActive (true);
text.gameObject.SetActive (true);
async = Application.LoadLevelAsync (s);
async.allowSceneActivation = false;
StartCoroutine (DisplayLoadingScreen ());
}
}
IEnumerator DisplayLoadingScreen ()
{
while (!async.isDone) {
loadProgress = (int)(async.progress * 100);
text.text = "Loading Progress " + loadProgress + "%";
progressBars.size = loadProgress;
yield return null;
}
if (async.isDone) {
Debug.Log ("Loading complete");
async.allowSceneActivation = true;
}
}
Comment
Your answer
Follow this Question
Related Questions
Making a function that executes once change things gradually 1 Answer
Setting up a function for sorting specific triggers entered based on a height integer. 0 Answers
how to make the sprite invinsible and reappear and how to call the sprite data from another script 0 Answers
C# 2D Top down game how to detect if objects are touching while they can pass through each other? 1 Answer
How to check if player is rapidly rotating the joystick? 2 Answers