using System.Collections; using System.Collections.Generic; using UnityEngine; public class Tester : MonoBehaviour { private Coroutine _crtn; private void Start() { this._crtn = this.StartCoroutine(this.HandleAnim()); } private IEnumerator HandleAnim() { float progress = 0f; float invDur = 1f / 5f; while (progress < 1f) { yield return new WaitForSeconds(0.2f); progress = Mathf.Clamp01(progress + (0.2f * invDur)); // Do something with progress Debug.Log(progress); } yield return this.StartCoroutine(this.subCoroutine()); // Cleanup? this._crtn = null; } private IEnumerator subCoroutine() { yield return new WaitForSeconds(1f); } }