타이핑 연출
This commit is contained in:
@@ -174,6 +174,34 @@ private AudioSource GetSfxSource()
|
||||
return source;
|
||||
}
|
||||
|
||||
//=========================== Looping SFX ===========================
|
||||
|
||||
//타이핑 사운드처럼 "시작 → 임의 시점에 정지"가 필요한 루프 재생.
|
||||
//반환값은 정지에 쓰는 핸들이다. PlaySFX와 달리 자동 반납되지 않으니 반드시 StopLoop를 부를 것.
|
||||
public AudioSource PlayLoop(AudioClip clip, float volume = 1f)
|
||||
{
|
||||
if (clip == null) return null;
|
||||
|
||||
AudioSource source = GetSfxSource();
|
||||
source.loop = true;
|
||||
source.clip = clip;
|
||||
source.volume = volume;
|
||||
source.Play();
|
||||
return source;
|
||||
}
|
||||
|
||||
//루프 재생을 멈추고 소스를 풀에 반납한다. 이미 반납된 소스(중복 호출)는 무시한다.
|
||||
public void StopLoop(AudioSource source)
|
||||
{
|
||||
if (source == null || !source.gameObject.activeSelf) return;
|
||||
|
||||
source.Stop();
|
||||
source.loop = false; //풀에 돌아가는 소스는 항상 loop=false 상태여야 한다
|
||||
source.clip = null;
|
||||
source.gameObject.SetActive(false);
|
||||
_sfxPool.Enqueue(source);
|
||||
}
|
||||
|
||||
//재생 길이만큼 대기 후 소스를 풀로 반납
|
||||
private async Awaitable ReturnAfterPlay(AudioSource source, float duration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user