public IEnumerator <WaitCommand> AnimateToMount(ICameraMount mount, TimeSpan duration) { if (_transitionActive) { Debug.LogError("Attempting to transition between mounts while another transition is still active"); yield break; } _transitionActive = true; yield return(Routines.Animate(_clock.PollDeltaTime, duration, lerp => { _rig.transform.position = Vector3.Lerp(_mount.transform.position, mount.transform.position, lerp); _rig.transform.rotation = Quaternion.Slerp(_mount.transform.rotation, mount.transform.rotation, lerp); }).AsWaitCommand()); if (_mount != null) { _mount.OnDismount(Rig); } _mount = mount; if (_mount != null) { _mount.OnMount(Rig); } _transitionActive = false; }
static IEnumerator <WaitCommand> FadeOut(string id) { yield return(Routines.Animate( () => 0.1.Seconds(), 1.Seconds(), value => Console.WriteLine("fade out " + value + " " + id), Routines.EaseInOutAnimation).AsWaitCommand()); }
public IEnumerator <WaitCommand> SetAlphaAsync(float targetAlpha, TimeSpan duration) { var startAlpha = _alpha; yield return(Routines.Animate(_clock.PollDeltaTime, duration, lerp => { float alpha = Mathf.Lerp(startAlpha, targetAlpha, lerp); SetAlpha(alpha); }).AsWaitCommand()); }
public static IEnumerator <WaitCommand> Animate(Transform mount, ICameraPath path, IClock clock) { // Wait at least one frame to prevent the editor from locking up when the duration is 0 if (path.Duration < TimeSpan.Zero) { yield return(WaitCommand.WaitForNextFrame); } yield return(Routines.Animate( clock.PollDeltaTime, path.Duration, lerp => { mount.position = Vector3.Lerp(path.From.Position, path.To.Position, lerp); mount.rotation = Quaternion.Lerp(path.From.Rotation, path.To.Rotation, lerp); }, path.Animation).AsWaitCommand()); }
private static IEnumerator <WaitCommand> Fade(IClock clock, TimeSpan duration, Routines.Animation animation, Action <float> fader) { yield return(Routines.Animate(clock.PollDeltaTime, duration, fader, animation).AsWaitCommand()); }