Xerios / ScreenManager

Flexible way to manage screens with transitions for Unity
MIT License
560 stars 69 forks source link

Question: why do you use WaitForSecondsRealtime(0.1f); instead of WaitForEndOfFrame()? #11

Closed kasradzenika closed 5 years ago

kasradzenika commented 5 years ago

In ScreenManager.cs, on line 114, why do you use WaitForSecondsRealtime(0.1f)? I'm assuming this is for optimization purposes but since it's fps-independent, isn't it going to degrade performance on low-end devices? For example, if the game is already lagging due to a scene loading this piece of code will still try to run.

Xerios commented 5 years ago

I doubt that it would degrade the performance in any noticeable way, maybe allocate few tiny bytes ( since unity's yield functions like WaitForSecondsRealtime are allocated ) but besides that it should still have a good performance.

Of course you could get away with yield return null or WaitForEndOfFrame() but that would put even more load since it would execute each frame.


To clarify, if the game is lagging due to loading for instance and a frame hangs for few seconds, WaitForSecondsRealtime should still execute the next frame since it uses current time to check if 0.1 seconds have passed. I could be wrong though, it's true that I haven't tested this case.