private IEnumerator FillBar() { // When the bar starts to fill, reset the timer. m_Timer = 0f; // The amount of time it takes to fill is either the duration set in the inspector, or the duration of the radial. float fillTime = m_SelectionRadial != null ? m_SelectionRadial.SelectionDuration : m_Duration; // Until the timer is greater than the fill time... while (m_Timer < fillTime) { // ... add to the timer the difference between frames. m_Timer += Time.deltaTime; // Set the value of the slider or the UV based on the normalised time. SetSliderValue(m_Timer / fillTime); // Wait until next frame. yield return(null); // If the user is still looking at the bar, go on to the next iteration of the loop. if (m_GazeOver) { continue; } // If the user is no longer looking at the bar, reset the timer and bar and leave the function. m_Timer = 0f; SetSliderValue(0f); yield break; } // If the loop has finished the bar is now full. m_BarFilled = true; // If anything has subscribed to OnBarFilled call it now. if (OnBarFilled != null) { OnBarFilled(); } // Play the clip for when the bar is filled. m_Audio.clip = m_OnFilledClip; m_Audio.Play(); LoadScene loadScene = GetComponent <LoadScene>(); loadScene.PlayGame(); // If the bar should be disabled once it is filled, do so now. if (m_DisableOnBarFill) { enabled = false; } }