private IEnumerator CheckProcess() { while (isTicking == true && IsPlaying() == true) { yield return(new WaitForSeconds(0.05f)); if (currentSound.HasLoop()) { switch (currentPlayingType) { case MusicPlayingType.SourceA: currentSound.CheckLoop(fadeA_audio); break; case MusicPlayingType.SourceB: currentSound.CheckLoop(fadeB_audio); break; case MusicPlayingType.AtoB: lastSound.CheckLoop(fadeA_audio); currentSound.CheckLoop(fadeB_audio); break; case MusicPlayingType.BtoA: lastSound.CheckLoop(fadeB_audio); currentSound.CheckLoop(fadeA_audio); break; } } } }
private IEnumerator CheckProcess() { while (isTicking == true && IsPlaying() == true) { yield return(new WaitForSeconds(0.05f)); if (currentSound.HasLoop() == true) { if (currentPlayingType == MusicPlayingType.SourceA) { currentSound.CheckLoop(fadeA_audio); } else if (currentPlayingType == MusicPlayingType.SourceB) { currentSound.CheckLoop(fadeB_audio); } else if (currentPlayingType == MusicPlayingType.AtoB) { lastSound.CheckLoop(fadeA_audio); currentSound.CheckLoop(fadeB_audio); } else if (currentPlayingType == MusicPlayingType.BtoA) { lastSound.CheckLoop(fadeB_audio); currentSound.CheckLoop(fadeA_audio); } } } }
//client api public void PlayBGM(SoundClip _clip) { if (IsDifferentSound(_clip) == true) { fadeB_audio.Stop(); lastSound = currentSound; currentSound = _clip; PlayAudioSource(fadeA_audio, _clip, 1.0f); if (currentSound.HasLoop() == true) { isTicking = true; DoCheck(); } } }
/// <summary> /// clip이 현재 진행중인 사운드가 아니라면 배경음악 교체 /// </summary> public void PlayBGM(SoundClip clip) { if (IsDifferentSound(clip)) { fadeB_audio.Stop(); lastSound = currentSound; currentSound = clip; PlayAudioSource(fadeA_audio, clip, clip.maxVolume); if (currentSound.HasLoop()) { isTicking = true; DoCheck(); } } }
public void FadeIn(SoundClip clip, float time, Interpolate.EaseType ease) { if (IsDifferentSound(clip) == true) { fadeA_audio.Stop(); fadeB_audio.Stop(); lastSound = currentSound; currentSound = clip; PlayAudioSource(fadeA_audio, currentSound, 0.0f); currentSound.FadeIn(time, ease); currentPlayingType = MusicPlayingType.SourceA; if (currentSound.HasLoop() == true) { isTicking = true; DoCheck(); } } }
public void FadeTo(SoundClip clip, float time, Interpolate.EaseType ease) { if (currentPlayingType == MusicPlayingType.None) { FadeIn(clip, time, ease); } else if (this.IsDifferentSound(clip)) { if (currentPlayingType == MusicPlayingType.AtoB) { fadeA_audio.Stop(); currentPlayingType = MusicPlayingType.SourceB; } else if (currentPlayingType == MusicPlayingType.BtoA) { fadeB_audio.Stop(); currentPlayingType = MusicPlayingType.SourceA; } lastSound = currentSound; currentSound = clip; lastSound.FadeOut(time, ease); currentSound.FadeIn(time, ease); //FadeTo A->B, B->A 사운드 교체 if (currentPlayingType == MusicPlayingType.SourceA) { PlayAudioSource(fadeB_audio, currentSound, 0.0f); currentPlayingType = MusicPlayingType.AtoB; } else if (currentPlayingType == MusicPlayingType.SourceB) { PlayAudioSource(fadeA_audio, currentSound, 0.0f); currentPlayingType = MusicPlayingType.BtoA; } if (currentSound.HasLoop()) { isTicking = true; DoCheck(); } } }
public void FadeTo(SoundClip _clip, float _time, Interpolate.EaseType _ease) { if (currentPlayingType == MusicPlayingType.None) { FadeIn(_clip, _time, _ease); } else if (IsDifferentSound(_clip) == true) { if (currentPlayingType == MusicPlayingType.AtoB) { fadeA_audio.Stop(); currentPlayingType = MusicPlayingType.SourceB; } else if (currentPlayingType == MusicPlayingType.BtoA) { fadeB_audio.Stop(); currentPlayingType = MusicPlayingType.SourceA; } //fade to lastSound = currentSound; currentSound = _clip; lastSound.FadeOut(_time, _ease); currentSound.FadeIn(_time, _ease); if (currentPlayingType == MusicPlayingType.SourceA) { PlayAudioSource(fadeB_audio, currentSound, 0.0f); currentPlayingType = MusicPlayingType.AtoB; } else if (currentPlayingType == MusicPlayingType.SourceB) { PlayAudioSource(fadeA_audio, currentSound, 0.0f); currentPlayingType = MusicPlayingType.BtoA; } if (currentSound.HasLoop()) { isTicking = true; DoCheck(); } } }