protected IEnumerator FinishWritingLetter() { //fade out to make the letter disappear double waitUntil = WorldClock.RealTime + 2f; while (WorldClock.RealTime < waitUntil) { yield return(null); } double fadeStartTime = WorldClock.RealTime; double fadeDuration = 2.0; if (VRManager.VRMode) { //do an actual camera fade mWaitingForCameraFade = true; CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, fadeDuration, 0f, () => { mWaitingForCameraFade = false; }); while (mWaitingForCameraFade) { yield return(null); } } else { //use the loading screen background //use the loading camera instead of fade in/out GUILoading.Get.BackgroundSprite.alpha = 0f; GUILoading.Get.BackgroundSprite.enabled = true; GUILoading.Get.gameObject.SetActive(true); GUILoading.Get.LoadingCamera.enabled = true; while (GUILoading.Get.BackgroundSprite.alpha < 1f) { GUILoading.Get.BackgroundSprite.alpha = (float)WorldClock.Lerp(GUILoading.Get.BackgroundSprite.alpha, 1f, (WorldClock.RealTime - fadeStartTime) / fadeDuration); if (GUILoading.Get.BackgroundSprite.alpha > 0.99f) { GUILoading.Get.BackgroundSprite.alpha = 1f; } yield return(null); } } //turn everything off and swap out the letters for (int i = 0; i < LetterWriter.LetterPages.Count; i++) { LetterWriter.LetterPages[i].SetActive(false); } LetterWriter.LetterTextObject.SetActive(false); MasterAudio.PlaySound(SoundType, WritingSounds[UnityEngine.Random.Range(0, WritingSounds.Count)]); LetterWriter.FinalLetter.SetActive(true); waitUntil = WorldClock.RealTime + 0.25f; while (WorldClock.RealTime < waitUntil) { if (VRManager.VRMode) { CameraFade.HoldAlphaFade(Colors.Alpha(Color.black, 1f)); } yield return(null); } MasterAudio.PlaySound(SoundType, PageTurnSound); Cutscene.CurrentCutscene.TryToFinish(); waitUntil = WorldClock.RealTime + 0.25f; while (WorldClock.RealTime < waitUntil) { if (VRManager.VRMode) { CameraFade.HoldAlphaFade(Colors.Alpha(Color.black, 1f)); } yield return(null); } fadeStartTime = WorldClock.RealTime; if (VRManager.VRMode) { //do an actual camera fade mWaitingForCameraFade = true; CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), true, fadeDuration, 0f, () => { mWaitingForCameraFade = false; }); while (mWaitingForCameraFade) { yield return(null); } } else { while (GUILoading.Get.BackgroundSprite.alpha > 0f) { GUILoading.Get.BackgroundSprite.alpha = (float)WorldClock.Lerp(GUILoading.Get.BackgroundSprite.alpha, 0f, (WorldClock.RealTime - fadeStartTime) / fadeDuration); if (GUILoading.Get.BackgroundSprite.alpha < 0.01f) { GUILoading.Get.BackgroundSprite.alpha = 0f; } yield return(null); } GUILoading.Get.BackgroundSprite.enabled = false; GUILoading.Get.LoadingCamera.enabled = false; GUILoading.Get.gameObject.SetActive(false); } ////Debug.Log ("GUI LETTER WRITER: Cutscene finished, releasing focus and destroying"); //GUIManager.Get.ReleaseFocus (this); //GameObject.Destroy (gameObject, 0.5f); //tell the cutscene we're finished }