Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.0 KiB

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);
}
}