using System; using System.Collections; using UnityEngine; public class WaitForLerp : IEnumerator { public object Current { get { return null; } } private float duration; private float timer; private Action act; public WaitForLerp(float seconds, Action act) { this.duration = seconds; this.act = act; } public bool MoveNext() { this.timer = Mathf.Min(this.timer + Time.deltaTime, this.duration); this.act(this.timer / this.duration); return this.timer < this.duration; } public void Reset() { this.timer = 0f; } }