![]() You will need to do a conversion using mixer.SetFloat(parameterName, Mathf.Log10(sliderValue) * 20) to get it nice and smooth (assuming sliderValue ranges from 0 to 1). And it’s not linear, so the slider won’t control the volume smoothly if you just map the volume directly from the slider to attenuation value. Note that the range of attenuation is -80 (muted) to 0 (full volume). Then, in code, you need to get a reference to the audio mixer (for example by adding a reference in a Monobehaviour and assigning it in the inspector) and set the volume of individual groups using the names of the parameters when they were exposed from the inspector. Then, the music audio source can specify that it should play through the music group, and all the others play through the sound effects group. You need to then expose the attenuation (volume) parameter of each group to code. The audio source component of the music is attached to GameObject name Sound.Īll the other audio sources components are effects and are in some places in the Hierarchy.Īn audio mixer lets audio sources specify which group they should output to, so you should create two groups, one for sounds effects, and one for music. My question/s is how to control with Slider only the volume of the music and with Slider (1) the effects volume ?Īnd how can i get all the effects audio sources in the script and control the volume of them using the Slider (1) ? Or maybe only the Music ? U'm not sure.īut when i change both sliders when the game is running it's changing the music volume. The problem is that the AudioListener in the script control all the Audio Sources. The music sound have his own Audio Source. Now in the Hierarchy I have some Audio Sources components for the sound effects and I want to control them with the Slider (1).Īnd to control the music sound with the Slider. Public class AudioManager : MonoBehaviourĪudioListener.volume = musicVolume.value ĪudioListener.volume = effectsVolume.value ![]() In the Hierarchy I have AudioPanel and two child Sliders.Īnd the AudioManager script that attached to the AudioPanel: using UnityEngine In the Hierarchy i have one Main Camera with Audio Listener.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |