Hello everyone, I had a problem with the sound settings. Added Slider to the settings that adjusts the volume of the sound (at least should adjust), but only adjusts the sound in the main menu and when you go to the game scene, the settings do not work. How can this be fixed?

using System.Collections; using System.Collections.Generic; using UnityEngine; public class scrAudio : MonoBehaviour { private AudioSource audioScr; private float musicVol = 1f; void Start() { audioScr = GetComponent<AudioSource>(); } void Update() { audioScr.volume = musicVol; } public void setVol(float Volue) { musicVol = Volue; } } 
  • And the AudioSource itself on another stage (sorry for the tautology) is another one or the same one, which has its settings changed? - Alexander Danilovsky
  • I decided to start making a prefab from the settings and throw it to another scene (I thought it would be a link and it would work) - shi fu

1 answer 1

Unity has such a thing as Audio Mixer . He is responsible for exactly how all the sounds will be displayed for the player. All AudioSource can set the sound channels inside the mixer and thus, before playing, all the sounds from the sources will pass through the settings of a particular channel.

In other words: you only need to adjust the volume in this mixer, and which source, from which scene or at what point it plays this sound - will not matter. In this case, you can add different sound effects to a specific audio channel.

There is a series of video lessons from Unity on this topic.