capri/autoloads/global_sounds.gd

18 lines
439 B
GDScript

@tool
extends Node
@export_tool_button("Update Sounds") var _update_sounds_action = _update_sounds
@export var sounds: Dictionary[StringName, AudioStreamPlayer]
func play_sound(id: StringName) -> void:
var sound := sounds.get(id) as AudioStreamPlayer
sound.play()
func _update_sounds() -> void:
sounds.clear()
for node in get_children():
if node is AudioStreamPlayer:
sounds[node.name] = node
notify_property_list_changed()