- Home /
Loading scene in background?
Hi, I have a scene that takes up to 30 seconds to load on weaker android devices (around 1ghz cpu). Iam trying to find a way to either shorten that time or make it to preload the files. Ive already searched for quite some time and tried some stuff (somehow I even managed to launch 2 scenes at the same time). The only thing that seemed to come close was a script that would load the scene while the first scene was running but it didnt wait for user to launch it, it just started the moment it was loaded. Does anyone know if I can make it to wait for the user to launch the scene?
Answer by whydoidoit · Apr 28, 2013 at 10:25 AM
Presumably you were using LoadLevelAsync?
var loader = Application.LoadLevelAsync("somelevel");
loader.allowSceneActivation = false;
//When ready
loader.allowSceneActivation = true;
See this: http://docs.unity3d.com/Documentation/ScriptReference/AsyncOperation-allowSceneActivation.html
Iam sorry but Iam not familiar with that type of variable, so I really dont know how to use it. Am I supposed to somehow execute that variable? I have no idea how to do that.
I'm a bit confused as I've given you all of the code you need.
Load the level like I show, then when you want to activate it set
loader.allowSceneActivation = true;
I dont know wtf just happend but now I cannot acces the scene I was working with. This is the script I used: var start : GUITexture; var loader = Application.LoadLevelAsync("game1");
function Start () {
loader.allowSceneActivation = false;
}
function Update () {
for (var touch : Touch in Input.touches){
if (start.HitTest (touch.position)){
if(touch.phase == TouchPhase.Began){
loader.allowSceneActivation = true;
}
}
}
}
When I tried it, it skipped the whole scene and just loaded the "game1". Now I cannot open that scene in unity. It just opens "game1" ins$$anonymous$$d. wtf? Every other scene is working.
Seems like the original scene now has the same size as the "game1". Could it be I somehow overwritten that scene?
after some testing it seems like what your script does is that it replaces current scene with the scene named in the script. I made a new scene, putted the script in there and did the same thing, replaced that scene with "game1".
Your answer
Follow this Question
Related Questions
Problems with Playerprefs script 1 Answer
Slow Android load times 0 Answers
put a void in an if statement? 1 Answer
How to transition from Load to scene ? 1 Answer
Scene loader Toutorial 0 Answers