- Home /
 
               Question by 
               kavaliero · Jan 29, 2014 at 08:32 PM · 
                coroutineloadlevelgui-button  
              
 
              LoadLevel at the end of a sound ! (pb with Coroutine)
Hello
I need to load a level at the end of a sound. It works fine the first time but when I reload the level with my coroutine it doesn't work anymore .
I got a menu with some buttons, one button leads to the Credits of my game . When I click on the Credits button my Credits scene is working. At the end of my Credits I get back to my first menu and if I click again on my Credits Button it doesn't work . I don't understand why. Please help me.
 void OnGui()
     {
       if (GUI.Button(new Rect [...]))
        {
          _soundManager.playSfx(SoundToPlayOnClick); // Play the sound
          if (_soundManager.IsSfxPlaying() == true) // check if the sound is playing
           {
             StartCoroutine(SetActionAfterSound(LevelToCall); 
           }
        }
     }
     
     public IEnumerator SetActionAfterSound(string level)
     {
        yield return new WaitForSeconds(_soundManager.getLengthOfCurrentSfx()); 
        UnityEngine.Application.LoadLevel(level);
     }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Running Coroutines Between Levels 4 Answers
Coroutine only starts when directly loading a scene from Unity editor. 1 Answer
Restart Current Level 2 Answers
LoadLevel break coroutine ? 1 Answer
Yield WaitForSeconds doesn't work, give syntax error 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                