IEnumerator FadeoutCoroutine(float time, System.Action action)
{
float endTime = Time.timeSinceLevelLoad + time * (cutoutRange);
var endFrame = new WaitForEndOfFrame ();
while (Time.timeSinceLevelLoad <= endTime) {
cutoutRange = (endTime - Time.timeSinceLevelLoad) / time;
fade.Range = cutoutRange;
yield return endFrame;
}
cutoutRange = 0;
fade.Range = cutoutRange;
if (action != null) {
action ();
}
}