private IEnumerator EnterTheVoid(SvManager svManager) { voidRunning = true; var delay = new WaitForSecondsRealtime(0.1f); var duration = 4f; var startTime = Time.time; var originalTimeScale = Time.timeScale; var targetTimeScale = 0.25f; var defaultEnvironment = SceneManager.Instance.defaultEnvironment; var originalSky = SceneManager.Instance.skyColor; var originalCloud = SceneManager.Instance.cloudColor; var originalWater = SceneManager.Instance.waterColor; var targetSky = Color.red; var targetCloud = Color.black; var targetWater = Color.cyan; var normalizedClip = 0.25f; while (Time.time < startTime + duration) { yield return(delay); var normalizedTime = (Time.time - startTime) / duration; float lerp; if (normalizedTime < normalizedClip) { lerp = normalizedTime / normalizedClip; } else if (normalizedTime >= 1f - normalizedClip) { lerp = (1f - normalizedTime) / normalizedClip; } else { lerp = 1f; } svManager.SvSetTimeScale(Mathf.Lerp(originalTimeScale, targetTimeScale, lerp)); svManager.SvSetSkyColor(Color.LerpUnclamped(originalSky, targetSky, lerp)); svManager.SvSetCloudColor(Color.LerpUnclamped(originalCloud, targetCloud, lerp)); svManager.SvSetWaterColor(Color.LerpUnclamped(originalWater, targetWater, lerp)); } svManager.SvSetTimeScale(originalTimeScale); if (defaultEnvironment) { svManager.SvSetDefaultEnvironment(); } else { svManager.SvSetSkyColor(originalSky); svManager.SvSetCloudColor(originalCloud); svManager.SvSetWaterColor(originalWater); } voidRunning = false; }