Performance: Creating and naming GameObjects
MEDIUM IMPACT
This affects the initial load time and runtime performance by influencing how many objects the engine must manage and how efficiently it can find and update them.
for (int i = 0; i < 1000; i++) { GameObject obj = new GameObject($"Enemy_{i}"); }
for (int i = 0; i < 1000; i++) { GameObject obj = new GameObject(); // No name assigned }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unnamed GameObjects | 1000 new nodes | N/A | N/A | [X] Bad |
| Named GameObjects | 1000 new nodes | N/A | N/A | [OK] Good |