18 lines
368 B
GDScript
18 lines
368 B
GDScript
@tool
|
|
extends HSlider
|
|
|
|
@onready var default_value = value
|
|
|
|
func _ready() -> void:
|
|
update_label(value)
|
|
value_changed.connect(update_label)
|
|
|
|
func update_label(x):
|
|
var p = (x - min_value) / (max_value - min_value)
|
|
$Label.text = "%.0f %%" % [ p * 100 ]
|
|
$Label.modulate = Color.BLUE.lerp(Color.RED, p)
|
|
|
|
func reset():
|
|
value = default_value
|
|
value_changed.emit(value)
|