Loading Screen JS

Hey guys!

I am looking to do a very simple loading screen when the player clicks play. There tends to be some hang time while the scene is prepared. So what I am doing is when they change to a different level, I would like to load a loadinglevel level, which will load the respective level, based on some other things.

Basically I am looking to have one scene that handles all of my larger loading. I would like just a simple bar that starts at zero and fills up while the level is loading. I think that is to be done using some kind of async, I am just not sure how to go about setting it up.

I found some other topics but they were all outdated. I am using the latest version of Unity 5.

Thanks guys!

This one doesn’t work: Link?

Okay I am so close but am having a strange issue… Everything loads… but for some reason my async.progress never shows that it is 100% It stops at 90.

I read in a few places that that is caused by setting allowSceneActivation to false. I am not doing this however.

The way I have it set up is really simple. I have my main game menu, when the player clicks New Game, it goes to my Loading scene. All my Loading scene does is it shows the word “Loading” + async.progress * 100 then in the Start() of the Loading scene I do this:

async = Application.LoadLevelAsync(1);

Also worth mentioning, I am not able to check isDone because it only ever equals 0.9… I can check progress but that stops at .9.

isDone is a boolean, true/false… I’ve not worked with async loading, but it might just not update progress when it’s completed the load? perhaps a

if(async.isDone)
{
// set text to show 100%
// wait a little while
// remove loading screen
}

is needed?

Just tried that, still hangs at 90 for a few seconds, then the level starts. It never prints anything out stating that async.isDone

Bump, does anyone have any idea?

Thanks!

Bump, anybody?

It seems like my game asynchronously is loading fine. It just never shows anything past 90.

I have no idea where you’re loading this, but I assume that once you’re done loading the level, the current level disappears. If this script is inside of the “current level”, then won’t it stop running the moment that loading of a new level is done? Is it on an object that’s set to DontDestroyOnLoad? You say that allowSceneActivation is not false, so it’s activating the new scene the moment that activation is possible, thus the counter never reaches 1 because the loop is being broken.

This seems like normal behaviour to me, but maybe I’m not understanding something about it. You may want to post on UnityAnswers rather than infinitely bumping a problem that clearly no one here has any interest in, or knowledge about (or whatever). Bunny83 would probably be able to answer it in about half a second, flat, so just post on Answers and wait for the magical rabbit to arrive.

Thank you for the reply, let me try to clear this up a bit.

I have a menu where the player selects what level they want to play. When they select a level, all it does is set a variable “_level” to the respective level. Then it loads my Loading scene. All my loading scene does is it takes in “_level” then I have it asynchronously load the respective level. The Update function in the loading scene is just a canvas UI text element which says "progress: " + async.progress; The async variable is the AsyncOperation.

All of the levels load fine from the menu to the loading screen. The issue is once the progress hits 90, I guess it still is loading, just it no longer updates to the screen. I have tried setting async.allowSceneActivation to false with the same results. Currently I have this set to true.