I’m not yet understanding the audio part to the end.
But what I did so far. I created a new Audio Mixer.
I created two new groups so now i have 3 groups: Master volume , Music volume, Effects volume.
You can see in the screenshot when the game is running when i move the slider in the game view window to the left just near the left side it’s like 0 but if i will keep move it to the fdar end left side it will get louder again. To the right it’s getting louder.
Same for the effects slider volume.
You can see also in the audio mixer on the second screenshot that the 0 value of the volume is near the top And -80 is at the bottom.
What i want to do is two things:
-
Making when the game is running if i move the slider to the left make it less louder the volume where 0(mute no sound) on the left side and most louder volume to the right end side. Same for both sliders.
-
To add something that will show me when the game is running each slider current value so when i’m changing the sliders left or right i will see the current value of the volume.
The main idea is to make that each slider most left side is mute not sound most right side volume is louder/higher and to display some ui for each slider volume current value. And make it smooth volume change left/right.
In general the volumes are working but not the way i want it by the values.
And this is the script i’m using for each slider in the On Value Changed in the inspector i’m calling each slider to it’s own method: SetMusicVolume() and SetEffectsVolume()
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Audio;
//[System.Serializable]
public class AudioManager : MonoBehaviour
{
public Slider musicVolume;
public Slider effectsVolume;
public AudioMixer audioMixer;
public void SetMusicVolume()
{
audioMixer.SetFloat("musicVol", Mathf.Log10(musicVolume.value) * 20);
}
public void SetEffectsVolume()
{
audioMixer.SetFloat("effectsVol", Mathf.Log10(effectsVolume.value) * 20);
}
}