Performance: WaitForSeconds and WaitForEndOfFrame
MEDIUM IMPACT
This affects frame rendering timing and responsiveness in Unity games or apps.
IEnumerator SmoothUpdate() {
while(true) {
yield return new WaitForEndOfFrame();
// lightweight logic here
}
}IEnumerator SlowUpdate() {
while(true) {
yield return new WaitForSeconds(0.5f);
// heavy logic here
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| WaitForSeconds with long delay | N/A | N/A | Delays frame updates causing lower responsiveness | [X] Bad |
| WaitForEndOfFrame | N/A | N/A | Syncs with frame end, smooth updates | [OK] Good |