unity滑条控制音量事件
slider.onValueChanged.AddListener
slider.onValueChanged.AddListener((float v) =>
{//v等价于slider.value
AudioTuning.Instance.SetMasterVolume(v);
});
AudioTuning:
public class AudioTuning : SingLeton<AudioTuning>
{
[SerializeField] AudioMixer audioMixer;
public void SetMasterVolume(float volume)
{
audioMixer.SetFloat("MasterVolume", volume);
}
}
Loading...