Ejemplo n.º 1
0
    IEnumerator LoadLevel()
    {
        SceneManager sceneManager = SceneManager.Instance;

        sceneManager.StartLoadLevelAsync(mainMenuLevelName, true);
        Authentication.BeginLogin();

        loadingBar.AssignLoadingBar(() =>
        {
            var authStatus = Authentication.GetAuthenticationStatus();
            if (authStatus == Authentication.AuthenticationStatus.LoggingIn)
            {
                return(0.2f);
            }
            else
            {
                return(Mathf.Lerp(0.2f, 1f, sceneManager.CurrentLevelLoadPercentage() / .9f));
            }
        });

        float timeout = Time.unscaledTime + 5f;

        while (!(sceneManager.CurrentLevelLoadPercentage() >= .9f &&
                 (Time.unscaledTime >= timeout || Authentication.GetAuthenticationStatus() == Authentication.AuthenticationStatus.LoggedIn ||
                  Authentication.GetAuthenticationStatus() == Authentication.AuthenticationStatus.ErrorLoggingIn)))
        {
            yield return(null);
        }

        yield return(new WaitForSeconds(2f));

        ScreenOverlay.Instance.Fade(ScreenOverlay.FadeType.Out, fadeTime, () =>
        {
            splashScreen2.SetActive(false);
            sceneManager.AllowLoadLevel();
        });
    }
Ejemplo n.º 2
0
 public void StartLoading(System.Func <float> callback)
 {
     loadingContent.SetActive(true);
     loadingBar.AssignLoadingBar(callback);
 }