auto-detect Music/FX bus in editor

When a player enters the tree in the editor, if its bus is still the default
"Master" and a "Music" (or "FX") bus exists in the AudioServer, switch to that.
User-customised buses are not overridden.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Samson
2026-04-29 15:00:56 +01:00
co-authored by Claude Opus 4.7
parent cb47d89377
commit 7f227acb6a
6 changed files with 30 additions and 6 deletions
+5 -1
View File
@@ -41,8 +41,12 @@ func _set(property: StringName, value: Variant) -> bool:
return false;
func _enter_tree() -> void:
if Engine.is_editor_hint() and stream == null:
if not Engine.is_editor_hint():
return;
if stream == null:
stream = AudioStreamPolyphonic.new();
if bus == &"Master" and AudioServer.get_bus_index("Music") != -1:
bus = "Music";
func _validate_property(property: Dictionary) -> void:
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]: