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.
}
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).
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 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.