Una Coroutine permite ejecutar código repartido a lo largo del tiempo sin bloquear el juego.
Necesita:
using System.Collections;
IEnumerator Esperar()
{
Debug.Log("Inicio");
yield return new WaitForSeconds(2f);
Debug.Log("Pasaron 2 segundos");
}
Ejecutar:
StartCoroutine(Esperar());
yield return new WaitForSeconds(1f);
Es afectado por Time.timeScale.
yield return new WaitForSecondsRealtime(1f);
No depende de timeScale.
yield return null;