- Home /
Issue with adding a Loading Screen
Here is the code. When i click play it runs this method.
IEnumerator LoadAsync(string SceneName)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(SceneName);
LoadingScreenGameObject.SetActive(true); //Displays the loading screen
while (!operation.isDone)
{
float progress = Mathf.Clamp01(operation.progress / .9f);
percentageText.text = progress * 100 + "%";
loadingSlider.value = progress;
yield return null;
}
}
And here is a GIF of the issue. http://gph.is/2x6gFKH The GIF is a little slow because of my crap Laptop. But as you can see i click the "Play" button and it hangs for a long period of time, goes to loading screen then instantly goes into the game. Why does it hang on the Menu rather than go to the Loading Screen then hang? Can anybody help please. Thank you
Answer by instruct9r · Aug 30, 2017 at 11:47 PM
You start loading before doing anything else.
If the scene, that you are trying to load is small, it will load it instantly, which will probably cause the freeze. Although it should load it instantly.
Anyway try this: First show the LoadingScreen and then start the AsyncLoading.
Your answer
![](https://koobas.hobune.stream/wayback/20220612133904im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Loading Bar in Different Scenes 1 Answer
Do we need pro version for loading progress in unity 5 ? 0 Answers
unity LoadSceneAsync works like LoadScene 0 Answers
Do I need a Loading Screen? 1 Answer
Loading Bar for Awake Function 1 Answer