public void InitialiseSlider(float recordingLength) { // Reset all internal variables isPlaying = false; timerCountUp = 0.0f; this.recordingLength = recordingLength; // Initialise the text and slider components to their minimum values CountUpTimer.text = RecordingTimerManager.TimeFloatToString(0.0f); PlaybackSlider.value = PlaybackSlider.minValue; CountDownTimer.text = RecordingTimerManager.TimeFloatToString(recordingLength); }
void Update() { if (isPlaying) { timerCountUp += Time.deltaTime; // If the timer count has reached or exceeded the recording length, stop playing and // set all of the components to their max values if (timerCountUp >= recordingLength) { StopPlaying(); CountUpTimer.text = RecordingTimerManager.TimeFloatToString(recordingLength); PlaybackSlider.value = PlaybackSlider.maxValue; CountDownTimer.text = RecordingTimerManager.TimeFloatToString(0.0f); } // Otherwise, simply set the text components and slider value CountUpTimer.text = RecordingTimerManager.TimeFloatToString(timerCountUp); PlaybackSlider.value = timerCountUp / recordingLength; CountDownTimer.text = RecordingTimerManager.TimeFloatToString(recordingLength - timerCountUp); } }