示例#1
0
    IEnumerator FadeIt()
    {
        while (!start)
        {
            //waiting to start
            yield return(null);
        }
        lastTime = Time.time;
        float coDelta    = lastTime;
        bool  hasFadedIn = false;

        while (!hasFadedIn)
        {
            coDelta = Time.time - lastTime;
            if (!isFadeIn)
            {
                //Fade in
                alpha = newAlpha(coDelta, 1, alpha);
                if (alpha == 1 && !startedLoading)
                {
                    startedLoading = true;
                    SceneManager.LoadScene(fadeScene);
                }
            }
            else
            {
                //Fade out
                alpha = newAlpha(coDelta, 0, alpha);
                if (alpha == 0)
                {
                    hasFadedIn = true;
                }
            }
            lastTime       = Time.time;
            myCanvas.alpha = alpha;
            yield return(null);
        }

        TransitionCoordinator.DoneFading();

        Debug.Log("Your scene has been loaded , and fading in has just ended");

        Destroy(gameObject);

        yield return(null);
    }
示例#2
0
 public void GoFade()
 {
     TransitionCoordinator.Fade(scene, loadToColor, 1.0f);
 }