using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SoundPlayer_BGM : MonoBehaviour { [Space(10)] public SoundPlayer intro; public SoundPlayer loop; [Space(10)] public SoundPlayer bgm; public void Play() { if(SoundManager.Instance.bgm != null) { if (SoundManager.Instance.bgm.audioSource.clip == intro.audioSource.clip || SoundManager.Instance.bgm.audioSource.clip == loop.audioSource.clip) return; } if (intro != null) { bgm = SoundManager.Instance.BGMPlay(intro.gameObject, true, () => { StopAllCoroutines(); }); StartCoroutine(Intro()); } else SoundManager.Instance.BGMPlay(loop.gameObject, true); } IEnumerator Intro() { while (bgm.audioSource.isPlaying) yield return null; SoundManager.Instance.BGMPlay(loop.gameObject, true); } }