- Home /
Web player not using load screen properly
Does anyone know why the unity web player does not use the load screen properly? http://dl.dropbox.com/u/52270474/WebPlayer.html
I've been hunting all over hells half acre trying to find a good load method.. how the hell do you do this... this is what I've been trying and it's clearly NOT frackin working!!
var progress : float = 0;
var pos : Vector2 = new Vector2(20,40);
var size : Vector2 = new Vector2(247,13);
var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;
private var loading : boolean = false;
var levelName : String;
function OnGUI()
{
GUI.DrawTexture(Rect(pos.x, pos.y, size.x, size.y), progressBarEmpty);
GUI.DrawTexture(Rect(pos.x, pos.y, size.x * Mathf.Clamp01(progress), size.y), progressBarFull);
}
function Update()
{
if(!loading && Application.GetStreamProgressForLevel(levelName) == 1)
progress = Time.time * 0.05;
Application.LoadLevel(levelName);
}
Why are you checking if "Application.GetStreamProgressForLevel(levelName)" equals one? It would only equal one when it is finished. This might be a problem
Answer by Bunny83 · Mar 24, 2012 at 02:07 AM
I've formated your code mess and indent the code the way you've programmed it. As you can see the if statement only covers the progress = Time.time * 0.05;
line.
Actually this line should be executed without any condition since it just fakes the progress and it doesn't make much sense to do this when the level is loaded.
All this is useless since Application.LoadLevel
is outside of your if-condition so it will be executed right away in the first frame.
The most important thing is: Have you build a streamed webplayer and considered all streaming-tips here ?
edit
Here how your Update function might should look like:
function Update()
{
progress = Time.time * 0.05;
if(!loading && Application.GetStreamProgressForLevel(levelName) == 1)
{
Application.LoadLevel(levelName);
}
}
It's ok to omit the brackets as long as you only want a single statement in the if-body, but it seems you're not that familiar with the common syntax.
I'm not sure I really follow, sorry for it messing up my code it does it every time, "Paste code here" so I do and instant F* Up. I'm NOT using Pro. so would any of this make a diference? I keep reading all sorts of crap about this?
Well I must admit Bunny83, it's working a little better, but $$anonymous$$aybe I'm not quite using it properly because although the load bar is actually moving now it finishes and there is still quite a bit of a wait before my level loads... not too long but a little bit of a wait... I was reading in the strea$$anonymous$$g tips to make my first level small.... maybe I need to make a small game level of the inside of Bud's house just so my players can kill a little time exploring and getting used to the controls?
"Application.GetStreamProgressForLevel()" is a float. This means that you can take the value, put it in a variable, and use it in the progress bar. Example:
function Update(){
var loadLevel = Application.GetStreamProgressForLevel(levelname)
progress = loadLevel * 0.05
if(!loading && Application.GetStreamProgressForLevel(levelname) == 1){
Application.LoadLevel(levelname)
}
}
I dunno, I can't tell if it's doing what it's supposed to maybe someone can check out the link and see if it's working at there end, it's seems to Frack up on $$anonymous$$e all the time something about "Bad File length" or something?!?! http://budthespudgame.net76.net/WebPlayer.html
There's something wrong with your webbuild. The file should be 34.3 $$anonymous$$B but it's just 15.6 $$anonymous$$B. $$anonymous$$aybe your hoster has a max file limit (around 16000 $$anonymous$$B ~ 15.625$$anonymous$$B) or your upload is corrupted. Check your filesize and whether your hoster has a limit or not.
edit
If i'm not on the wrong hoster it seems they don't have a limit. So check the filesize on your server and compare it with your local file (compare the byte values, not $$anonymous$$B or $$anonymous$$B) and reupload it if the file is corrupted.