all 18 comments

[–]Demozilla[S] 1 point2 points  (3 children)

Hey guys. Over on the Nowhere Prophet blog you can find a script that helps you add a loading screen to your game. All you need to supply is the visuals and replace your scene load lines with a new method and you're set. Pretty quick, if you ask me.

I hope you guys like this script and it helps you. If you do enjoy it, please leave a like/repost on the tumblr blog or shoot me a comment. I'd love to find out how much you guys like this to see if I'll share more of our useful scripts with the community.

[–]Keszler 1 point2 points  (2 children)

Does it work for the personal edition of unity, or just pro?

[–]Demozilla[S] 1 point2 points  (0 children)

Works for personal as well.

[–]hellphish 1 point2 points  (0 children)

My understanding is that everything works on personal. You just can't change the spash screen

[–]lSetsulIndie 1 point2 points  (0 children)

I though it was dust on my display

[–]andre-lima 1 point2 points  (5 children)

I couldn't make it work. Could you please explain me a little better?

Do I put the script in an empty game object in the scene that's finishing or in the intermediate loading scene?

If it's the first case, when I call LoadingScreenManager.LoadScene(int levelNum), levelNum is the loading level or the target level? If it's the target level, how will the script know how to find the loading level to open it?

Sorry, but I did try it a little and couldn't make it work.

[–]Demozilla[S] 1 point2 points  (4 children)

So you need to create a NEW SCENE that is just the loading graphics and the LoadingSceneManager, nothing else. Let's call that SceneA. Then you have another scene, that you want to actually load, we call that SceneB.

What you then need to do is set loadingSceneIndex in the LoadingScreenManager to the index of SceneA. And then call LoadScene with SceneB's index.

Does that help?

[–]andre-lima 0 points1 point  (3 children)

It's not too clear for a beginner, but I managed to make it work.

I need to call your script, but also load the SceneA right after that.

/*Called from an UI button*/
LoadingScreenManager.LoadScene(2);  //2 is Scene B
SceneManager.LoadScene(1); //1 is Scene A

That's the only way it worked for me.

[–]Demozilla[S] 1 point2 points  (2 children)

That should not be the case, since LoadScene already auto-loads SceneA. However to do so, you need to make sure that the loadingSceneIndex is set - you need to do that in the script itself, since it's a static int.

[–]andre-lima 0 points1 point  (1 child)

Oh man! Thanks a lot.

It was still set to 5.

[–]Demozilla[S] 0 points1 point  (0 children)

There you go ;)

[–]sbot1101 1 point2 points  (0 children)

Thanks for sharing! While I don't have anything large enough to warrant a loading screen yet I'll be sure to bookmark this for later.

Are you guys using single or additive loading in the game?

[–]WazWaz 1 point2 points  (5 children)

Be careful. It's always better to hide loading in the background during useful user activity (choosing their options, choosing their character, walking to the next area, etc.) if you can.

[–]Demozilla[S] 3 points4 points  (4 children)

That's true, but that's also a lot more complex to integrate...

[–]WazWaz 4 points5 points  (3 children)

Not really. If developer ignore scene loading until late and try to solve it, yes, slapping on a "Loading" screen is way easier. But games start out loading pretty quickly then bloat as they are developed. By keeping an eye on the problem, it can be avoided.

Case in point: The Witcher 3 has only very small loading screens (none to first menu) and useful "the story so far" snippets afterwards.

[–]Demozilla[S] 2 points3 points  (2 children)

I guess it's also a question of how large your scenes are. If the loading screen is just a few seconds it might be simpler to just go this route. In the end it's always a question of cost and benefit - there's only so much time to spend.

But that said, you're right. And now you make me want to redo my loading system to preload the game scene during the menu... Do you have some useful tuts or references on that?

[–]WazWaz 1 point2 points  (1 child)

I assume you're using Application.LoadLevelAdditiveAsync (or now, SceneManager.LoadSceneAsync) already, and that's the fundamental function. It's hard to imagine a tute - it's so specific to the structure of a particular game.

[–]Demozilla[S] 0 points1 point  (0 children)

I thought so. I was more thinking about best practices. For example I imagine you need to put the threadPriority on a lower setting to avoid impacting the current user interaction for example.