using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Level1 { public class AudioManager : MonoBehaviour { AudioSource bgmSource; AudioSource effect; public AudioClip bgm; public AudioClip error; public AudioClip end; public AudioClip pb; private void Awake() { bgmSource = gameObject.AddComponent(); bgmSource.playOnAwake = false; bgmSource.loop = true; bgmSource.volume = 0.5f; effect = gameObject.AddComponent(); effect.playOnAwake = false; effect.loop = false; GameManager.StartGame += PlayPB; GameManager.StartGame += PlayBGM; } private void OnEnable() { bgmSource.clip = bgm; } void PlayBGM() { bgmSource.loop = true; bgmSource.Play(); } public void PlayErrorEffect() { effect.clip = error; effect.Play(); } public void PlayEnd() { effect.clip = end; effect.Play(); } public void PlayPB() { effect.clip = pb; effect.Play(); } } }