using UnityEngine;
[RequireComponent
(typeof(UISlider
))] public class UIVolumeSlider : MonoBehaviour
{
public AudioSource audioSource;
void Awake ()
{
UISlider slider = GetComponent<UISlider>();
slider.sliderValue = audioSource.volume;
slider.eventReceiver = gameObject;
}
void OnSliderChange (float val)
{
audioSource.volume = val;
}
}