示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (clipRecording.IsRecording())
        {
            timer += Time.deltaTime;

            waveform.DrawWaveform();

            if (timer >= recordTime)
            {
                clipRecording.StopRecording();
            }
        }
        else if (clipRecording.IsPlaying())
        {
            if (clipRecording.GetPlayDir() > 0)
            {
                if (timer < recordTime)
                {
                    timer += Time.deltaTime;
                }

                if (timer >= recordTime)
                {
                    clipRecording.StopClip(audioSrc);
                }
            }
            else if (clipRecording.GetPlayDir() < 0)
            {
                if (timer > 0)
                {
                    timer -= Time.deltaTime;
                }

                if (timer <= 0)
                {
                    clipRecording.StopClip(audioSrc);
                }
            }
        }
        waveform.SetPlayhead(timer / recordTime);
    }
示例#2
0
 void Update()
 {
     waveform.SetPlayhead(audioSource.time / audioSource.clip.length);
 }
示例#3
0
        // Update is called once per frame
        void Update()
        {
            if (isCountdown)
            {
                countdownTimer += Time.deltaTime;

                if (countdownTimer >= countdownTime)
                {
                    isCountdown        = false;
                    countdownText.text = "";
                    Record();
                }
                else
                {
                    countdownText.text = Mathf.CeilToInt(countdownTime - countdownTimer).ToString();
                }
            }
            else if (clipRecording.IsRecording() && !recorded)
            {
                playTimer += Time.deltaTime;

                waveform.DrawWaveform();

                if (playTimer >= recordTime)
                {
                    CompleteRecording();
                }
            }
            else if (clipRecording.IsPlaying())
            {
                if (clipRecording.GetPlayDir() > 0)
                {
                    if (playTimer < recordTime)
                    {
                        playTimer += Time.deltaTime;
                    }

                    if (playTimer >= recordTime)
                    {
                        clipRecording.StopClip(audio);
                    }
                }
                else if (clipRecording.GetPlayDir() < 0)
                {
                    if (playTimer > 0)
                    {
                        playTimer -= Time.deltaTime;
                    }

                    if (playTimer <= 0)
                    {
                        clipRecording.StopClip(audio);
                        if (!playedBackwards)
                        {
                            playedBackwards = true;
                            transistion.Show(nextDialog);
                            Hide();
                        }
                    }
                }
            }
            waveform.SetPlayhead(playTimer / recordTime);
        }