loading screen

hey guys, i’ve got two questions =) i was wondering firstly is it possible to create a loading screen in unity similar to most other games? i wouldn’t know how to access a % or variable to say how much has loaded ect.

secondly, when i export my game for a windows stand alone, when i go to run the game i get a box that pops up with options like graphics, resolutions ect is it possible to disable this and have it in an ingame options instead? thanks alot!

To show a loading screen, the best way is to create an intermediate scene that does nothing but show the progress bar and use LoadLevelAsync to load in the new level. The AsyncOperation object returned when you call LoadLevelAsync has a progress field that lets you see how far the loading has got:-

var async: AsyncOperation;

function Start () {
    async = Application.LoadLevelAsync ("MyLevel");
    yield async;
}

function Update() {
   var progress = async.progress;
   // Do something with this value here.
}

And for the second part: Go to Edit > Project Settings > Player and disable the Display Resolution Dialog.

great thanks alot guys :smile:!

hey, could i ask for some support on this? sorry im a tad bad at scripting =)

var async: AsyncOperation;
var LoadingComplete = 100;

var Loc = 400;
var Locx = 20;
var Locy = 20;

function Start () {
	async = Application.LoadLevelAsync ("Level_human");
	yield async;
}

function Update () {
	var progress = async.progress;
	print ("progress");
}


function OnGUI () {
	GUI.Box(Rect(Locx,Locy,Loc /2 /(LoadingComplete / progress), 20), progress + "%"); 
	}

im aware that prgress cant be in the GUI statement becuase progress isn’t an int, but i hope you can see what im tyring to do with this script and point me in the right direction.

also when i try without the GUI part i get the error null refernce execption, ofcourse this is whilst its attached to the only thing in the scene( a camera).

bumpp =)

You have declared the progress variable as a local variable in the Update function. This means that its value is not available in OnGUI. There should be no problem if you refer to async.progress directly in OnGUI.

According to this thread the progress only returns 0 (not completed) or 1 (completed) making it impossible to really use .progress for anything useful.

So still no way to make a loading progress bar in Unity?

I believe the AsyncOperation.progress is a float, so it might be bringing back a percentage, have you check that?

Sadly the AsyncOperation.progress only returns 0 or 1. It cannot be used for a progress bar. I am not even sure why it exists unless it is broken.

try with this

Application.GetStreamProgressForLevel

It’s no help. Any solution? :frowning:

I have the same problem with my loadscreens, The game seems to be locked when I call LoadLevelAsync and when the scene finishes loading and Update is called again the async progress is 1, sometimes I get a 0.9. So it’s useless for updating a progressbar, in fact any sort of animation such as the classic spinning wheel will freeze while the level loads.

So unless the docs are wrong or we all miss understood how this function works I’d say this is a bug. Maybe related to the changes made on scene loading for Unity3. As it stand right now LoadLevelAsync and LoadLevel do pretty much the same thing.

Same problem for me … It doesn’t load “async” at all. I have unity 3.3

Is that another Unity bug?

Same here: LoadLevelAsync is not actually “async”. I’m using Unity 3.2 Pro.

i have found that LoadLevelAsync is working but async.progress is not working

an animted screen can be show while loading but it is not possible to display

Hi,andeeee, it seems that async.progress does not work, it will return either 0 or 1, no value between them.

async.isDone can be used as well if you experience problems with async.progress. It will not give the progress though.