IEnumerator DelayedLoad(int scene) { //Play the clip once source.PlayOneShot(select); float fadeTime = fade.BeginFade(1); //Wait until clip finish playing yield return(new WaitForSeconds(fadeTime)); //Load scene here SceneManager.LoadScene(scene); }
IEnumerator ChangeLevel() { FadeInOut fadeInOut = GameObject.Find("Character Main Camera").GetComponent <FadeInOut>(); float fadeTime = fadeInOut.BeginFade(1); yield return(new WaitForSeconds(fadeTime)); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); }
public void Restart() { fade.BeginFade(1); StartCoroutine(DelayedLoad(SceneManager.GetActiveScene().buildIndex)); }