Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

LoadLevel at the end of a sound ! (pb with Coroutine)

$
0
0
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); }

Viewing all articles
Browse latest Browse all 171066

Trending Articles