Performance: Slider and progress bars
MEDIUM IMPACT
This concept affects the rendering performance and responsiveness of UI elements that update frequently, impacting smoothness and input delay.
void Update() {
float newValue = GetLoadingProgress();
if (Mathf.Abs(progressBar.value - newValue) > 0.01f) {
progressBar.value = newValue;
}
}void Update() {
progressBar.value = GetLoadingProgress();
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Update every frame without check | High (many UI updates) | 60+ per second | High (continuous redraws) | [X] Bad |
| Update only on significant value change | Low (few UI updates) | Few per second | Low (minimal redraws) | [OK] Good |