How to adjust game sound from UI Slider?

Hello guys! I’m just wondering how to adjust a audio in which my slider is on the other scene example “Main Menu” while the game sound is on the Next scene which is the game itself. How can I do that? Im a beginner. Thanks for your response :slight_smile:


Here 3 easy options: On Slider change …

  • create a global float value on one scene, retrieving it in the other one and applying that float to the Audio Source Volume (Globals stay across scenes, but get resettet when restarting or exiting the game)
  • change the overall game volume with

public float volume = 1.0f; //1.0f = 100% Volume, 0.0f = 0% Volume (mute) | instead of a hardcoded value like “1.0f” you should get the slider value, so that it applies this to the audio
AudioListener.volume = volume.Value;

  • use PlayerPrefs, wich Values even stay when you leave or close the game:

PlayerPrefs.SetFloat(“Game Volume”, 1.0f); //in the first scene; “Game Volume” is the name of the (unique) Key you create and the float value afterwards is the value of that Key, both can be changed to your liking

public float volume = PlayerPrefs.GetFloat(“Game Volume”); //in the other scene, then apply that value to the Audio Source Volume you want to control