Use IEnumerator as delay

Hi! I just wonder if I keep using StartCoroutine/ IEnumerator as delay for play animation then run other function.
Will the timing different in different mobile or computer?
for example…
if I fade in for a scene

img.GetComponent().SetBool(“fadeIn”, true);
yield return new WaitForSeconds(1f);
then do something else.

WaitForSeconds works fine for about 1/4th of a second or more. 1 second is 1 second on any platform.

The main problem is with yield return null;. That waits until next frame, which is obviously twice as long at 30FPS over 60 (and even worse if the editor is running at 100+). The other problem is with very small times. Unity only waits in frames. If you tell it to wait for 1/50th of a second, all Unity can do at 60FPS is wait 2 frames, which is really 1/30th of a second. You can use both of those things, but you have to do extra work to keep the times the same.

1 Like

Thank You