Quick answer: WaitForSeconds uses Time.deltaTime which is zero when timeScale = 0. Use WaitForSecondsRealtime for unscaled timing in pause menus and similar UI.

Here is how to fix Unity coroutines that freeze whenever you pause via Time.timeScale = 0. UI animations stop, menu transitions never complete. The fix is the unscaled variant of WaitForSeconds.

The Symptom

You set Time.timeScale = 0 to pause the game. The pause menu starts a coroutine to fade in, but it never advances. Releasing the pause makes the coroutine catch up suddenly.

What Causes This

WaitForSeconds is scaled. Tied to Time.deltaTime which respects timeScale. At 0, no time passes.

Manual lerps with deltaTime. Same issue: the increment is zero.

Animator default scaled. Animator update mode is Normal (scaled) by default.

The Fix

Step 1: Use WaitForSecondsRealtime.

using System.Collections;
using UnityEngine;

public class PauseMenu : MonoBehaviour
{
    public IEnumerator FadeIn(CanvasGroup g)
    {
        float t = 0;
        while (t < 1)
        {
            t += Time.unscaledDeltaTime / 0.5f;   // 0.5s fade
            g.alpha = t;
            yield return null;            // runs every frame regardless of timescale
        }
    }
}

yield return null always advances; pair with unscaledDeltaTime for correct progression.

Step 2: Use WaitForSecondsRealtime for delays.

yield return new WaitForSecondsRealtime(0.5f);
// runs even when paused

Step 3: Animator update mode. On the Animator, set Update Mode to Unscaled Time for UI animators that should run during pause. Game-world animators stay on Normal.

Step 4: Use Tween libraries with unscaled time option. DOTween, LeanTween, etc. expose an UpdateType.UnscaledTime parameter. Pass it for paused-menu tweens.

Step 5: Avoid mixing scaled and unscaled in one effect. A fade using Time.unscaledDeltaTime triggering audio that uses Time.deltaTime produces inconsistent timing during pause. Pick one model per effect.

“Pause = scaled stops. WaitForSecondsRealtime + unscaledDeltaTime keep UI alive.”

Related Issues

For async/await deadlocks, see async/await Deadlock. For framerate cap, see Frame Rate Cap.

WaitForSecondsRealtime. unscaledDeltaTime. Animator unscaled. UI animates during pause.