public float PerformFill(float points, float startAt = 0) { var achievedQuality = Quality.CalculateLevelFromPoints(points); Debug.Log("Moving up " + achievedQuality + " levels."); fillAmount = 0; UpdateFillAmount(); Sequence seq = DOTween.Sequence(); for (int i = 0; i < (int)achievedQuality.x; i++) { // Add a new bar fill animation. seq.Append(foregroundTransform.DOSizeDelta(new Vector2(-barMaxWidth, barHeight), LevelUpEaseDuration) .SetEase(LevelUpEase).OnComplete(() => MoveUpQualityLevel())); } // Fill remaining percentage. fillAmount = achievedQuality.y; float fill = -Mathf.Lerp(barMinWidth, barMaxWidth, fillAmount); seq.Append(foregroundTransform.DOSizeDelta(new Vector2(fill, barHeight), .8f).SetEase(Ease.Linear)); seq.SetEase(OverallEase); seq.Play(); return(seq.Duration()); }