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
@@ -17,8 +17,12 @@ extends AudioStreamPlayer2D
var _core : DynamicSoundFXPlayerCore;
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("FX") != -1:
bus = "FX";
func _ready() -> void:
_core = DynamicSoundFXPlayerCore.new(self);