- Home /
LoadLevelAdditive delay
Hi, i have a loading scene with every object in the scene parented to ONE empty game object and a script attached to it.
function Update(){
Application.LoadLevelAdditive("Game2");
Destroy(this.gameObject);
}
So basically this script loads the scene "Game2" but it changes scenes so fast that you cant even see the loading screen...so i want a delay before the script changes scene, is there a way to do it? ( i tried using waitforseconds but that didnt work cause it will just stay at the loading scene)
Answer by iRaMb0 · Jan 20, 2013 at 08:17 AM
Wow i actually fixed it :) Instead of function Update i had to use function Start ( as Geo.Ego said) and use a different function for the loading part :
function Start(){
yield WaitForSeconds(3);
Load();
}
function Load(){
Application.LoadLevelAdditive("Game2");
Destroy(this.gameObject);
}
Answer by Geo.Ego · Jan 16, 2013 at 04:50 PM
A few things: if you're going to use yield WaitForSeconds
, you need to use it an IEnumerator
block that is called by StartCoroutine
. Also, since this is only going to happen once, you'd probably want to put it in Start
instead of your Update
function. Try this:
private IEnumerator LoadNextScene ()
{
yield return new WaitForSeconds (5.0f); // Change this float to the number of seconds to delay for.
Application.LoadLevelAdditive("Game2");
}
void Start ()
{
StartCoroutine (LoadNextScene ());
}
is this a C# script?It obviously isn't java so i tried it in C# and i got this error : (10,6): error CS0116: A namespace can only contain types and namespace declarations
Your answer
Follow this Question
Related Questions
Load level / prefabs without causing hiccups 1 Answer
Load Level Additive Async Lag spike 0 Answers
Better way for a timer to load a level? 1 Answer
allowSceneActivation give me error message 0 Answers
load level when no enemy car are left 2 Answers