public void LoadScene(UnityScene scene, float timeout) { if (!isStarted) { StartCoroutine(FadeOut(scene, timeout)); } }
public void LoadScene(UnityScene scene) { if (!isStarted) { StartCoroutine(FadeOut(scene, 0.0f)); } }
private IEnumerator FadeOut(UnityScene scene, float timeout) { isStarted = true; yield return(new WaitForSeconds(timeout)); for (float t = 0.0f; t < 1; t += Time.deltaTime / fadeOutTime) { panel.material.color = new Color(0, 0, 0, Mathf.Lerp(0, 1, t)); yield return(null); } SceneManager.LoadScene(scene); }