IEnumerator FadeIn(bool outlinesFade) { float thisDuration = fadeDuration; if (!outlinesFade) { thisDuration *= 2f; } float elapsedTime = 0; float ratio = elapsedTime / thisDuration; Color fader = background.color; //fade from black to balck with white outlines while (ratio < 1f) { elapsedTime += Time.unscaledDeltaTime; ratio = elapsedTime / thisDuration; ratio *= 2; ratio = Mathf.Clamp(ratio, 0f, 1f); Color newColor = Color.Lerp(Color.black, Color.clear, ratio); SoundTrackManager.SetDynamicVolume(ratio); pauseMenuGroup.alpha = 1f - ratio; background.color = newColor; yield return(null); } SoundTrackManager.SetDynamicVolume(1f); elapsedTime = 0f; ratio = elapsedTime / thisDuration; if (outlinesFade)//fade from white outlines to scene { while (ratio < 1f) { elapsedTime += Time.unscaledDeltaTime; ratio = elapsedTime / thisDuration; edge.PauseMenu = 1f - ratio; yield return(null); } } transitionIsDone = true; Resume(false); }
IEnumerator FadeOut() { float elapsedTime = 0; float ratio = elapsedTime / fadeDuration; Color fader = background.color; while (ratio < 1f) { elapsedTime += Time.deltaTime; ratio = elapsedTime / fadeDuration; Color newColor = Color.Lerp(fader, Color.black, ratio); SoundTrackManager.SetDynamicVolume(1 - ratio); //edge.PauseMenu = ratio; background.color = newColor; pauseMenuGroup.alpha = 1f - ratio; yield return(null); } SoundTrackManager.SetDynamicVolume(0); }