Solved: Loading screen shows up late and disappears too fast...

Hello,

I want to have a loading screen that appears as quick as possible (when starting the game) and shows up until the game is loaded.

When I search for it, I found multiple samples and all go like this:

Create a new scene, put your loading Image and or label on it, and load your original Scene then in a script.

public class LevelManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //SceneManager.LoadScene(1);
        StartCoroutine(LoadNewScene());
    }

    IEnumerator LoadNewScene()
    {
        // Start an asynchronous operation to load the scene that was passed to the LoadNewScene coroutine.
        AsyncOperation async = SceneManager.LoadSceneAsync(1);
        // While the asynchronous operation to load the new scene is not yet complete, continue waiting until it's done.
        while (!async.isDone)
        {
            yield return null;
        }
    }
}

But the Problem is this:

Unity logo is shown very fast. After that there is a very Long loading with a black screen, then there is my Scene with my image but just for half a second…game starts.
I am aware I could add a waiting time before loading the game scene but this is no useful solution…

I guess this is because of my many ressources?

How can I have my loading screen appear much earlier, when the loading is Happening?

Thanks a lot!

Hello,
My first guess would be that other scripts load before LevelManager.
In Project Settings, there is a tab “Script Execution Order”, maybe you’d want to try and put yours ahead of non-dependent scripts you’re not using.
I’m not sure 100% percent it’s what happening here, just that it might get you closer to what you are trying to achieve.

I’ve also found this post on the forums regarding the loading screen after the splash that may help too.

Have a nice day !

1 Like

Do somethin like this:

        private IEnumerator AsynchronousLoad(int scene) {
            isLoading = true;

            _asyncOp = SceneManager.LoadSceneAsync(scene);
            _asyncOp.allowSceneActivation = false;
            while(!_asyncOp.isDone) {
                if(Mathf.Approximately(_asyncOp.progress, 0.9f)) {
                    _asyncOp.allowSceneActivation = true;
                    FadeScreenFromBlack(1.0f);
                }
                yield return null;
            }

            yield return new WaitForEndOfFrame();
            isLoading = false;
            yield return null;
        }
1 Like

Yes, this fixed it:

yield return new WaitForSeconds(0.1f);

Just added before my LoadSceneAsync…

Thanks!

No it doesnt fix it.
You must use _asyncOp.allowSceneActivation = false; until _asyncOp.progress is almost 0.9f and then you must enable it.

No it fixed and works perfect. It Shows my Intro Scene and my Image very early.
The Build is set to my Scene “Intro”. It just contains my Image on my canvas with the above script.

It Shows up early and loads the other Scene. When using your Code, it only Shows the Image again for a very late and short time…

but thanks for the help!

It doesnt fix it, you are just lucky on your computer.
You must check if issplashscreenfinished and you must activate the next loaded scene after you are done with the current.

Thanks for the hint, I’ll try that.

Okay, I am now using your Code,
and in the first line I added

yield return new WaitForSeconds(0.1f);

Then my Image appears very early and stays while loading…

If I do not add this line, I only see it very late after loading for just half a second.

Thanks for helping!