Esempio n. 1
0
    private IEnumerator SceneLoading(String nextScene)
    {
        // Clear up whatever leftover form last scene.
        ClearUp();

        // Appear loading scene.
        yield return(new WaitForEndOfFrame());

        ScreenFadeControl screenFadeControl = DarkestDungeonManager.Instance.GetScreenFadeContorl;

        screenFadeControl.Appear();

        // Wait for the appear animation to finished.
        yield return(new WaitForSeconds(1f));

        // Asynchrony load the next scene in the backgroun.
        async = SceneManager.LoadSceneAsync(nextScene);

        // Pervent the next scene active itself after loading finished.
        async.allowSceneActivation = false;

        // Keep loading until loading complete
        while (!async.isDone)
        {
            // Since we set scene activation to FALSE, loading process will only progress up to 0.9
            if (async.progress >= 0.9f)
            {
                break;
            }
            else if (onLoadingProgressUpdated != null)
            {
                // keep updating the loading progress event.
                Debug.Log("check A");
                onLoadingProgressUpdated(async.progress);
            }

            yield return(null);
        }
        yield return(new WaitForSeconds(0.5f));

        screenFadeControl.FadeOut();
        yield return(new WaitForSeconds(1f));

        // Active scene after loading complete.
        async.allowSceneActivation = true;

        Debug.Log("check");

        if (onLoadingProgressUpdated != null)
        {
            onLoadingProgressUpdated(async.progress);
        }

        screenFadeControl.Appear();
    }
Esempio n. 2
0
 private void init()
 {
     screenFadeContorl = GetComponentInChildren <ScreenFadeControl>();
 }