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:
co-authored by
Claude Opus 4.7
parent
cb47d89377
commit
7f227acb6a
@@ -18,8 +18,12 @@ extends AudioStreamPlayer
|
|||||||
var _core : DynamicSoundFXPlayerCore;
|
var _core : DynamicSoundFXPlayerCore;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("FX") != -1:
|
||||||
|
bus = "FX";
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_core = DynamicSoundFXPlayerCore.new(self);
|
_core = DynamicSoundFXPlayerCore.new(self);
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ extends AudioStreamPlayer2D
|
|||||||
var _core : DynamicSoundFXPlayerCore;
|
var _core : DynamicSoundFXPlayerCore;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("FX") != -1:
|
||||||
|
bus = "FX";
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_core = DynamicSoundFXPlayerCore.new(self);
|
_core = DynamicSoundFXPlayerCore.new(self);
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ extends AudioStreamPlayer3D
|
|||||||
var _core : DynamicSoundFXPlayerCore;
|
var _core : DynamicSoundFXPlayerCore;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("FX") != -1:
|
||||||
|
bus = "FX";
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_core = DynamicSoundFXPlayerCore.new(self);
|
_core = DynamicSoundFXPlayerCore.new(self);
|
||||||
|
|||||||
@@ -42,8 +42,12 @@ func _set(property: StringName, value: Variant) -> bool:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("Music") != -1:
|
||||||
|
bus = "Music";
|
||||||
|
|
||||||
func _validate_property(property: Dictionary) -> void:
|
func _validate_property(property: Dictionary) -> void:
|
||||||
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
||||||
|
|||||||
@@ -41,8 +41,12 @@ func _set(property: StringName, value: Variant) -> bool:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("Music") != -1:
|
||||||
|
bus = "Music";
|
||||||
|
|
||||||
func _validate_property(property: Dictionary) -> void:
|
func _validate_property(property: Dictionary) -> void:
|
||||||
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
||||||
|
|||||||
@@ -41,8 +41,12 @@ func _set(property: StringName, value: Variant) -> bool:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
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();
|
stream = AudioStreamPolyphonic.new();
|
||||||
|
if bus == &"Master" and AudioServer.get_bus_index("Music") != -1:
|
||||||
|
bus = "Music";
|
||||||
|
|
||||||
func _validate_property(property: Dictionary) -> void:
|
func _validate_property(property: Dictionary) -> void:
|
||||||
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
if property.name in ["RandomMinPitchScale", "RandomMaxPitchScale"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user