SliderClip.cs 552 B

12345678910111213141516171819202122232425262728
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class SliderClip : MonoBehaviour {
  6. public AudioClip SliderAudio;
  7. private Slider slider;
  8. void Start () {
  9. slider = GetComponent<Slider>();
  10. if(slider != null)
  11. {
  12. slider.onValueChanged.AddListener(delegate { PlayAudio(); });
  13. }
  14. }
  15. public void PlayAudio()
  16. {
  17. if(SliderAudio != null)
  18. {
  19. SoundManager.Instance.UIAudioPlay(SliderAudio);
  20. }
  21. }
  22. }