How to show a temporary popup in a paused escape menu for a Unity game

Save Menu

Save Menu

Most menus in Unity will set the time scale to 0 in order to pause the game. This will prevent other timed coroutines from running. The way around this is to create a coroutine within a coroutine.

 

public static IEnumerator WaitForRealSeconds(float time)
{
float start = Time.realtimeSinceStartup;
while (Time.realtimeSinceStartup < start + time)
{
yield return null;
}
}

public IEnumerator showPopup()
{
saveFeedback.SetActive(true); // Display GUI object for a window
yield return StartCoroutine(WaitForRealSeconds(.8f));
saveFeedback.SetActive(false);// Hide GUI object for a window
}

void Start() {

StartCoroutine(showPopup());

}