Advertisement
Neverknow247

utils.gd

Oct 5th, 2023 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Node
  2.  
  3. var volume_settings = {
  4.     "master_volume" = 1,
  5.     "music_volume" = 1,
  6.     "sfx_volume" = 1,
  7.     "voice_volume" = 1
  8. }
  9.  
  10. const master_bus_name = "Master"
  11. const music_bus_name = "Music"
  12. const sfx_bus_name = "SFX"
  13. const voice_bus_name = "Voice"
  14.  
  15. @onready var master_bus = AudioServer.get_bus_index(master_bus_name)
  16. @onready var music_bus = AudioServer.get_bus_index(music_bus_name)
  17. @onready var sfx_bus = AudioServer.get_bus_index(sfx_bus_name)
  18. @onready var voice_bus = AudioServer.get_bus_index(voice_bus_name)
  19.  
  20. func set_volume():
  21.     AudioServer.set_bus_volume_db(master_bus, linear_to_db(volume_settings["master_volume"]))
  22.     AudioServer.set_bus_volume_db(music_bus, linear_to_db(volume_settings["music_volume"]))
  23.     AudioServer.set_bus_volume_db(sfx_bus, linear_to_db(volume_settings["sfx_volume"]))
  24.     AudioServer.set_bus_volume_db(voice_bus, linear_to_db(volume_settings["voice_volume"]))
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement