I have a scene called AudioTrigger, when the player walks in this box, it plays a sound. It’s just a simple colision box that has an AudioStreamPlayer in it. I like to have everything organized in one place so I want to add all the variables that need to be changed frequently due to experimentation in the top node and then pass them to the child nodes via code. One thing that I need to change via the top node is the AudioBus of the AudioStreamPlayer. Now, I know how to set the bus, but how do I export a variable of type “AudioBus”. Can it be done? I would like to have something like a drop down menu like in AudioStreamPlayer or an empty spot to drag-n-drop the bus into, but I can’t find it anywhere online. Does someone know if this can be done or how to do it? Thank you very much!
I’ve tried to do this but I just can’t get it to work. Am I doing something wrog?
I’ve just copy-pasted the code from the documentation:
extends Node
@export var is_number_editable: bool:
set(value):
is_number_editable = value
notify_property_list_changed()
@export var number: int
func _validate_property(property: Dictionary):
if property.name == "number" and not is_number_editable:
property.usage |= PROPERTY_USAGE_READ_ONLY
but when I save the file and then tick and untick the is_number_editable property in the inspector, no matter the state of the boolean I can still change the value of number. Am I doing something wrong?
After a LOT of fiddling I finally came up with a solution. This is the code for anyone in the future:
enum AudioBus {}
@export var audio_bus: AudioBus
func _validate_property(property: Dictionary):
if property.name == "audio_bus":
var busNumber = AudioServer.bus_count
var options = ""
for i in busNumber:
if i > 0:
options += ","
var busName = AudioServer.get_bus_name(i)
options += busName
property.hint_string = options