Skip to content

Commit 12c21c3

Browse files
committed
Update volume_slider.gd
In VolumeSlider.set_value_programmatically, you always propagate the clamped value to AudioServer and AudioManager even if it hasn’t changed; adding a short-circuit when is_equal_approx(clamped_value, _previous_value) is true would avoid redundant backend calls and keep behavior consistent with _on_value_changed’s duplicate-guard.
1 parent c179b1d commit 12c21c3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

scripts/ui/components/volume_slider.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ func set_value_programmatically(new_value: float) -> void:
8686
# Clamp to the slider's configured range to avoid UI/backend divergence
8787
var clamped_value: float = clamp(new_value, min_value, max_value)
8888

89+
# Early return: Prevent redundant backend I/O if the value hasn't changed
90+
if is_equal_approx(clamped_value, _previous_value):
91+
return
92+
8993
# Godot 4 native method: updates visual value without emitting 'value_changed'
9094
set_value_no_signal(clamped_value)
9195

0 commit comments

Comments
 (0)