I notice there is an OnLevelWasLoaded function and a CanStreamedLevelBeLoaded
function but no OnStreamedLevelReady (or similar) that I can find.
So do you just have to constantly check CanStreamedLevelBeLoaded in an Update function until its ready, assuming you want to load it as soon as possible. Isn’t that very inefficient? or is there a better way to deal with this?
In general you’ll need to write some sort of polling routine to check if a destination level is ready to load or not. Whether you use an Update loop, or some sort of coroutine is up to you.
That’s good to know.
I have it working in the Update loop now, but when the scene loads in a streamed web app it makes a terrible mess of my lighting and doesn’t seem to run some scripts etc. basically streaming is very broken for me. I’ve reported a bug hopefully this will get fixed at some point or I can get a pro license and use some other method to get my models in whilst the player is running. Otherwise my download times are going through the roof…
Does this function definetely work? I find on most browsers it seems to be returning true even though the content hasn’t loaded yet.
private var level1Loaded : boolean = false;
function Start() {
waitForLoad();
}
function waitForLoad () {
while (!Application.CanStreamedLevelBeLoaded(1)) {
yield WaitForSeconds (2);
}
Application.LoadLevelAdditive(1);
level1Loaded = true;
}
function OnGUI() {
if (level1Loaded) {
if (GUI.Button ( Rect(splashBox.width - 100, splashBox.height - 55, 100, 45), GUIContent ("Next", nextIcon, "next screen"), picIconStyle ) ) {
print ("clicked");
}
}
}
But my GUI.Button turns up even when the content isn’t loaded… it just appears straight away, and in IE7 you can even see at the bottom of the screen that the page is still loading. It works when run locally just not off a real server. What’s going on?