- Home /
Wait For Seconds to Load level C#
Hi how do I make my level load after yielding for seconds in C#.
So far i've got.
 IEnumerator()
 {
     yield return new WaitForSeconds(5);
     Application.LoadLevel(5);
 
 }
It doesn't work how do i make this work. In java it works just find what the heck does C#need?
Thanks ~K
Please format any code you post and make sure the tags you use are spelled correctly.
Answer by Bunny83 · Jul 18, 2011 at 11:49 PM
Well, i just wanted to like this page but unfortunately the C# example is wrong xD
At least the examples here: MonoBehaviour.StartCoroutine are correct.
You need to use StartCoroutine to start a coroutine and your function needs a name btw...
 IEnumerator MyLoadLevel(float delay, int level)
 {
     yield return new WaitForSeconds(delay);
     Application.LoadLevel(level);
 }
 
 
 StartCoroutine(MyLoadLevel(5.0f,5));
Answer by khalil · Jul 19, 2011 at 12:11 PM
okay thats what i needed thanks a bunch.
I temporarily fixed the problem by making a coroutine in java, then i threw it inside standard assets and was able to call it from my C# scripts. I'm glad you gave me this example though, i will be using it. If only the Unity Scripting guide would settle down and actually list REAL examples then we wouldn't have such issues with SIMPLE things..
lol Thanks again ~K
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                