public static IEnumerator MoveTo(this Transform transform, Vector3 target, float duration, Easer ease, AutoDel p_del) { float elapsed = 0; var start = transform.localPosition; var range = target - start; while (elapsed < duration) { elapsed = Mathf.MoveTowards(elapsed, duration, Time.deltaTime); transform.localPosition = start + range * ease(elapsed / duration); yield return 0; } transform.localPosition = target; p_del(); }
public static IEnumerator AltOverFreq(AutoDel p_true, AutoDel p_false, float duration, int freq) { float elapsed = 0; float freqElapsed = 0; float freqDuration = duration / freq; bool temp = false; //Debug.Log ("freq"); while (elapsed < duration) { elapsed = Mathf.MoveTowards (elapsed, duration, Time.deltaTime); if (freqElapsed < freqDuration) { freqElapsed = Mathf.MoveTowards (freqElapsed, freq, Time.deltaTime); } else { freqElapsed = 0; temp = (temp == false) ? true : false; AutoDel call = (temp) ? p_true : p_false; call(); //Debug.Log (temp); //Debug.Log("freq"); //call(); freqElapsed = Mathf.MoveTowards (freqElapsed, freq, Time.deltaTime); yield return 0; } yield return 0; } }
public static IEnumerator MoveTo(this Transform transform, Vector3 target, float duration, EaseType ease, AutoDel p_del) { return MoveTo(transform, target, duration, Ease.FromType(ease), p_del); }