@@ -58,14 +58,9 @@ func get_sound_volume() -> float:
5858 return db_to_linear (AudioServer .get_bus_volume_db (AudioServer .get_bus_index (sound_effects .bus )))
5959
6060
61- func get_ui_sound_volume () -> float :
62- return db_to_linear (AudioServer .get_bus_volume_db (AudioServer .get_bus_index (ui_sound_effects .bus )))
63-
64-
6561func set_sound_volume (volume_between_0_and_1 : float ) -> void :
6662 _show_shared_bus_warning ()
6763 AudioServer .set_bus_volume_db (AudioServer .get_bus_index (sound_effects .bus ), linear_to_db (volume_between_0_and_1 ))
68- AudioServer .set_bus_volume_db (AudioServer .get_bus_index (ui_sound_effects .bus ), linear_to_db (volume_between_0_and_1 ))
6964
7065
7166func play_sound (resource : AudioStream , override_bus : String = "" ) -> AudioStreamPlayer :
@@ -82,6 +77,24 @@ func stop_sound(resource: AudioStream) -> void:
8277 return sound_effects .stop (resource )
8378
8479
80+ func set_default_sound_bus (bus : String ) -> void :
81+ sound_effects .bus = bus
82+
83+
84+ #endregion
85+
86+ #region UI sounds
87+
88+
89+ func get_ui_sound_volume () -> float :
90+ return db_to_linear (AudioServer .get_bus_volume_db (AudioServer .get_bus_index (ui_sound_effects .bus )))
91+
92+
93+ func set_ui_sound_volume (volume_between_0_and_1 : float ) -> void :
94+ _show_shared_bus_warning ()
95+ AudioServer .set_bus_volume_db (AudioServer .get_bus_index (ui_sound_effects .bus ), linear_to_db (volume_between_0_and_1 ))
96+
97+
8598func play_ui_sound (resource : AudioStream , override_bus : String = "" ) -> AudioStreamPlayer :
8699 return ui_sound_effects .play (resource , override_bus )
87100
@@ -96,10 +109,6 @@ func stop_ui_sound(resource: AudioStream) -> void:
96109 return ui_sound_effects .stop (resource )
97110
98111
99- func set_default_sound_bus (bus : String ) -> void :
100- sound_effects .bus = bus
101-
102-
103112func set_default_ui_sound_bus (bus : String ) -> void :
104113 ui_sound_effects .bus = bus
105114
@@ -209,6 +218,8 @@ func set_default_music_bus(bus: String) -> void:
209218
210219
211220func _show_shared_bus_warning () -> void :
221+ if "Master" in [music .bus , sound_effects .bus , ui_sound_effects .bus , ambient_sounds .bus ]:
222+ push_warning ("Using the Master sound bus directly isn't recommended." )
212223 if music .bus == sound_effects .bus or music .bus == ui_sound_effects .bus :
213224 push_warning ("Both music and sounds are using the same bus: %s " % music .bus )
214225
0 commit comments