public IEnumerator <WaitCommand> Animate(Transform mount, Predicate isRunning) { var pathSelection = _cameraPaths.Paths; var selectedPath = pathSelection.RandomElement(); var isFirst = true; while (isRunning()) { selectedPath = pathSelection.GetNext(selectedPath); if (_gameSettingsProvider.IsVrActive) { selectedPath = new StaticCameraPath( Routines.LinearAnimation, selectedPath.Duration, selectedPath.To, to: selectedPath.To); } IEnumerator <WaitCommand> fadeIn; if (isFirst) { fadeIn = WaitCommand.DontWait.AsRoutine; isFirst = false; } else { fadeIn = _rig.ScreenFader.FadeIn(_clock, _faderSettings); } var fadeOut = WaitCommand.Wait(selectedPath.Duration - _faderSettings.FadeOutDuration) .AndThen(_rig.ScreenFader.FadeOut(_clock, _faderSettings)); var cameraAnimation = CameraAnimator.Animate(mount, selectedPath, _clock); yield return(WaitCommand .Interleave(fadeIn, cameraAnimation, fadeOut) .RunWhile(isRunning) .AsWaitCommand()); } _rig.ScreenFader.Opacity = 0f; }
private void Disconnect() { StartCoroutine(cameraAnimator.Animate()); }
private void PlayExitMenuAnimationAndConnect() { StartCoroutine(cameraAnimator.Animate()); StartCoroutine(AudioManager.FadeOut()); }