コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // Volume controlled by sin wave! With max volume of 75% and start delay of 4s
        float timeMult = ((Time.timeSinceLevelLoad - 4f) % TIME_MUSIC_DURATION) / TIME_MUSIC_DURATION;
        float volume   = Mathf.Sin(Mathf.PI * 2 * timeMult) / 2 + 0.25f;

        //Debug.Log(volume);
        if (!musicSrc.isPlaying && volume >= -0.1f)
        {
            musicSrc.Play();
        }
        else if (musicSrc.isPlaying && volume <= -0.1f)
        {
            musicSrc.Stop();
        }
        if (volume < 0)
        {
            volume = 0;
        }
        musicSrc.volume = volume;


        // ESC / Android BACK button
        if (Input.GetKey(KeyCode.Escape))
        {
            fade.FadeLaunch(null);
        }

        // Touch input
        foreach (Touch touch in Input.touches)
        {
            if (touch.phase == TouchPhase.Began)
            {
                OnTapDown(touch.position);
            }
        }

        // Mouse click
        if (Input.GetMouseButtonDown(0))
        {
            OnTapDown(Input.mousePosition);
        }
    }
コード例 #2
0
 public void OnBackButton()
 {
     fade.FadeLaunch("Launcher");
 }