public IEnumerator RunModeRoutine(Mode targetMode) { FaderObject.SetActive(true); var color = targetMode.TouchSphere.Color; _faderMaterial.SetColor("_Color", color); foreach (var m in Modes) { if (m.TouchSphere.gameObject.activeSelf) { m.TouchSphere.LerpToScale(0f, 0.3f, true); } if (m.Panel.gameObject.activeSelf) { m.Panel.LerpToScale(0f, 0.3f, true); } } for (var i = 0f; i < 1f; i += Time.deltaTime / FlashFadeTime) { color.a = 1f - i; _faderMaterial.SetColor("_Color", color); yield return(null); } FaderObject.SetActive(false); IntroCanvas.gameObject.SetActive(true); IntroCanvas.SetPositionInstantly(); var text = targetMode.ArtistName; if (targetMode.Panel.InfiniteModeToggle.CurrentValue) { text += "\n\nInfinite mode - hold the menu button to return"; } IntroCanvas.SetTexts(targetMode.SongName, text, targetMode.Tip); IntroCanvas.Fade(1f, 1f); yield return(new WaitForSeconds(5f)); IntroCanvas.Fade(0f, 1f, true); LeftController.gameObject.SetActive(true); RightController.gameObject.SetActive(true); LeftHaptics.enabled = true; RightHaptics.enabled = true; MenuToggler.AllowMenuToggle = true; for (var i = 0f; i < 1f; i += Time.deltaTime / 0.5f) { var iL = 0f; if (i < 0.5f) { iL = 4f * i * i * i; } iL = (i - 1f); iL = 4f * iL * iL * iL + 1f; LeftController.localScale = new Vector3(iL, iL, 1f); RightController.localScale = new Vector3(iL, iL, 1f); MeditationTriggers.GlobalSizeMultiplier = 1f - i; } MeditationTriggers.GlobalSizeMultiplier = 0f; LeftController.localScale = Vector3.one; RightController.localScale = Vector3.one; SettingsApplicator.TestJson = targetMode.PresetJson; UiSettingsApplicator.LoadFromJson(targetMode.PresetJson.text); SettingsApplicator.ApplyTestJson(); PsyiaRenderer.RenderMaterial.color = new Color(0f, 0f, 0f, 0f); PsyiaRenderer.enabled = true; PsyiaDispatcher.RunOnUpdate = true; targetMode.Emitter.Emit(SettingsApplicator.CurrentSettings.System.MaxParticleCount * 1024); Music.SetClip(targetMode.Song); Music.AutoPlay = targetMode.Panel.InfiniteModeToggle.CurrentValue; if (AudioData.Instance.AudioDetected) { Music.AutoPlay = true; } else { Debug.Log(Music.IsPlaying); Music.PlayPause(); Debug.Log(Music.IsPlaying); } SaveGameInterface.Main.PlayCount++; for (var i = 0f; i <= 1f; i += Time.deltaTime / 2f) { PsyiaRenderer.RenderMaterial.color = Color.Lerp(new Color(0f, 0f, 0f, 0f), DefaultPsyiaColor, i); yield return(null); } //note - this means that if Auto Play is on, the only way back is using the menu button! while (Music.TimeInTrack < targetMode.Song.length - 5f || Music.AutoPlay) { yield return(null); } IntroCanvas.gameObject.SetActive(true); IntroCanvas.SetPositionInstantly(); IntroCanvas.SetTexts(targetMode.SongName, targetMode.ArtistName, targetMode.Tip); IntroCanvas.Fade(1f, 2f); for (var i = 0f; i <= 1f; i += Time.deltaTime / 5f) { PsyiaRenderer.RenderMaterial.color = Color.Lerp(DefaultPsyiaColor, new Color(0f, 0f, 0f, 0f), i); yield return(null); } PsyiaRenderer.RenderMaterial.color = new Color(0f, 0f, 0f, 0f); PsyiaRenderer.enabled = false; PsyiaDispatcher.RunOnUpdate = false; yield return(new WaitForSeconds(2f)); IntroCanvas.Fade(0f, 1f, true); for (var i = 0f; i < 1f; i += Time.deltaTime / 0.5f) { var iL = 0f; if (i < 0.5f) { iL = 4f * i * i * i; } iL = (i - 1f); iL = 4f * iL * iL * iL + 1f; iL = 1f - iL; LeftController.localScale = new Vector3(iL, iL, 1f); RightController.localScale = new Vector3(iL, iL, 1f); MeditationTriggers.GlobalSizeMultiplier = i; } MeditationTriggers.GlobalSizeMultiplier = 1f; LeftController.localScale = Vector3.zero; RightController.localScale = Vector3.zero; ReturnToMenu(); }