21 lines
535 B
GDScript3
Raw Normal View History

2024-02-16 23:27:55 +00:00
@tool
extends Slider
var bus := -1
func _ready():
bus = AudioServer.get_bus_index(get_parent().name)
var db := AudioServer.get_bus_volume_db(bus)
var linear := db_to_linear(db)
set_value_no_signal(linear)
func on_value_changed(new_value: float):
AudioServer.set_bus_volume_db(bus, linear_to_db(new_value))
func _get_configuration_warnings() -> PackedStringArray:
var warnings := []
if AudioServer.get_bus_index(get_parent().name) == -1:
warnings.append("Invalid audio bus name: %s" % get_parent().name)
return warnings