Ejemplo n.º 1
0
    private IEnumerator AsyncLoadLevel(int targetScene)
    {
        fader.BeginFadeToBlack(false);

        while (fader.fadeProgress < 0.95)
        {
            yield return(null);
        }

        fader.ToggleLoadingUIOn(true);

        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(targetScene);

        while (!asyncLoad.isDone)
        {
            // Here you put your loading screen code.
            fader.UpdateSlider(asyncLoad.progress);

            yield return(null);
        }

        // You don't need to turn the text and slider back off or call BeginFadeToClear() here as the old scene will now be destroyed.
        // The new scene that was just loaded asynchonously will replace it and should have a SceneManager object in it to handle fading etc.
    }