SoundManager.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SoundManager : Singleton<SoundManager> {
  5. public AudioSource UI_AudioSource;
  6. public AudioSource ambient_AudioSource;
  7. public AudioSource music_AudioSource;
  8. public AudioSource fx_AudioSource;
  9. public void UIAudioPlay(AudioClip _clip)
  10. {
  11. UI_AudioSource.clip = _clip;
  12. if (SoundDataGlobal.OnOffSoundUI && SoundDataGlobal.OnOffSound)
  13. {
  14. UI_AudioSource.Play();
  15. }
  16. }
  17. public void FXAudioPlay(AudioClip _clip)
  18. {
  19. fx_AudioSource.clip = _clip;
  20. if (SoundDataGlobal.OnOffSoundFx && SoundDataGlobal.OnOffSound)
  21. {
  22. fx_AudioSource.Play();
  23. }
  24. }
  25. public void AmbientAudioPlay(AudioClip _clip)
  26. {
  27. music_AudioSource.clip = null;
  28. ambient_AudioSource.clip = _clip;
  29. if (SoundDataGlobal.OnOffSound)
  30. {
  31. ambient_AudioSource.Play();
  32. }
  33. }
  34. public void MusicAudioPlay(AudioClip _clip)
  35. {
  36. ambient_AudioSource.clip = null;
  37. music_AudioSource.clip = _clip;
  38. if (SoundDataGlobal.OnOffSoundMusic && SoundDataGlobal.OnOffSound)
  39. {
  40. music_AudioSource.Play();
  41. }
  42. }
  43. public void StopMusicAudioSource()
  44. {
  45. music_AudioSource.Stop();
  46. }
  47. public void StopAmbientAudioSource()
  48. {
  49. ambient_AudioSource.Stop();
  50. music_AudioSource.Stop();
  51. }
  52. public void PlayMusicAudioSource()
  53. {
  54. music_AudioSource.Play();
  55. }
  56. public void PlayAmbientAudioSource()
  57. {
  58. music_AudioSource.Play();
  59. ambient_AudioSource.Play();
  60. }
  61. }