Performance: Why UI communicates game state
MEDIUM IMPACT
This concept affects how quickly the game UI updates to reflect changes, impacting interaction responsiveness and visual stability.
void OnScoreChanged(int newScore) { scoreText.text = newScore.ToString(); } void OnHealthChanged(float newHealth) { healthBar.value = newHealth; } // Subscribe to game state events and update UI only when values change
void Update() {
scoreText.text = gameState.score.ToString();
healthBar.value = gameState.health;
// Updates every frame regardless of changes
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Update UI every frame | High (many updates) | Many reflows triggered | High paint cost | [X] Bad |
| Update UI on state change | Minimal updates | Single or few reflows | Low paint cost | [OK] Good |