private IEnumerator Run(IMorph target, float directionOffset) { float time = 0, previousTime = 0; while (_duration > 0 && (time < 1 || (previousTime < 1 && time >= 1))) { target.Frame(Mathf.Abs(directionOffset - Mathf.Clamp01(time))); previousTime = time; time += Time.deltaTime / _duration; yield return(null); } }
private IEnumerator Run(IMorph target, float directionOffset) { var steps = _intermediateSteps + 2; var waitBetweenSteps = new WaitForSeconds(_durationInSeconds / steps); var stepSize = 1f / (steps - 1); for (int i = 0; i < steps; i++) { target.Frame(Mathf.Clamp01(Mathf.Abs(directionOffset - i * stepSize))); yield return(waitBetweenSteps); } }
public void Frame(float time) { _source.Frame(_easingCurve.Evaluate(time)); }