Performance: Scene creation and management
HIGH IMPACT
This affects how quickly scenes load and switch, impacting the user's wait time and smoothness of gameplay transitions.
StartCoroutine(LoadSceneAsync("Level2")); IEnumerator LoadSceneAsync(string sceneName) { AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName); asyncLoad.allowSceneActivation = false; while (!asyncLoad.isDone) { if (asyncLoad.progress >= 0.9f) { asyncLoad.allowSceneActivation = true; } yield return null; } }
SceneManager.LoadScene("Level2");| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous LoadScene | N/A | Blocks main thread causing frame freeze | High paint delay | [X] Bad |
| Async LoadScene with allowSceneActivation | N/A | Non-blocking main thread | Smooth paint updates | [OK] Good |
| Sequential scene loads without additive | N/A | Multiple reloads and reflows | High paint cost | [X] Bad |
| Additive scene loading | N/A | Single load plus additive, minimal reloads | Low paint cost | [OK] Good |