示例#1
0
    private void Update()
    {
        float dt = Time.deltaTime;

        beatTimer += Time.deltaTime;

        float time       = Time.time;
        float clipLength = audioMesh.AudioSrc.clip.length;

        // hacky stuff that works for the audio clip that I have used
        if (time % clipLength >= 38.0f)
        {
            if (time % clipLength >= 327.0f)
            {
                // close corridor at second 327
                currCorridorTargetWidth = closedCorridorWidth;
                titleText.Hide();
            }
            else
            {
                // open corridor at second 38
                currCorridorTargetWidth = openedCorridorWidth;
                titleText.Show();
            }
        }
        else
        {
            currCorridorTargetWidth = closedCorridorWidth;
        }

        bool  shouldSunset = (time % clipLength + transitionTime) / clipLength >= 1.0f;
        float dir          = shouldSunset ? -1.0f : 1.0f;

        timer += (dt * dir);
        timer  = Mathf.Clamp(timer, 0.0f, transitionTime);
        float t = timer / transitionTime;

        t = EaseOutSine(t);

        UpdateConfig(sunsetConfig, zenithConfig, t);
        UpdateCorridorWidth();

#if UNITY_STANDALONE
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
#endif
    }