コード例 #1
0
    public IEnumerator UpdateColor()
    {
        float m_CurrentTime  = 0.0f;
        float fadeTime       = 3.0f;
        float introTime      = 16.0f;
        float totalTime      = fadeTime + introTime;
        bool  isPlayingIntro = false;

        while (m_CurrentTime <= totalTime)
        {
            m_CurrentTime += Time.deltaTime;

            if (Input.anyKey)
            {
                m_CurrentTime = totalTime;
                m_AudioSource.Stop();
            }

            if (m_CurrentTime <= fadeTime)
            {
                float t = Mathf.Clamp(m_CurrentTime / fadeTime, 0.0f, 1.0f);
                t             = EasingFunctions.OutQuat(t);
                m_Image.color = Color.Lerp(m_StartingColor, m_TargetColor, t);
            }
            else if (!isPlayingIntro)
            {
                m_AudioSource.clip = m_IntroClip;
                m_AudioSource.Play();
                isPlayingIntro = true;
            }
            yield return(new WaitForEndOfFrame());
        }

        Debug.Log("Transition to next scene");
        SceneManager.LoadScene("Scenes/FinalStudioApartment", LoadSceneMode.Single);
    }