29 lines
845 B
GDScript
29 lines
845 B
GDScript
extends TextureButton
|
|
|
|
class_name SoundTextureButton
|
|
|
|
@export var audio_collections: Array[AudioStreamCollection]
|
|
|
|
func _ready():
|
|
if !audio_collections:
|
|
audio_collections.append(preload("res://config/audio/ui/ui_click.tres"))
|
|
#print("sound button loaded default ui_click.tres")
|
|
|
|
if audio_collections:
|
|
#print("sound button load audio_collections into audio_player")
|
|
var audio_player := RandomAudioStreamPlayer.new()
|
|
audio_player.audio_collections = audio_collections
|
|
button_down.connect(audio_player.play_random)
|
|
add_child(audio_player)
|
|
else:
|
|
printerr("sound button has no audio_collections! ignore initialization of audio_player")
|
|
#button_down.connect(_on_press_down)
|
|
#button_up.connect(_on_press_up)
|
|
|
|
|
|
#func _on_press_down():
|
|
#InputUtil.set_cursor_hand_patting()
|
|
#
|
|
#func _on_press_up():
|
|
#InputUtil.set_cursor_hand_rest()
|