public void FadeIn(SoundClip m, float time, Interpolate.EaseType ease) { if (this.CheckPlay(m)) { this.fadeA_audioSource.Stop(); this.fadeB_audioSource.Stop(); this.lastSound = this.currentSound; this.currentSound = m; if (this.currentSound != null) { this.currentSound.PreLoad(); } this.fadeA_audioSource.clip = this.currentSound.GetClip(); this.fadeA_audioSource.volume = 0; this.fadeA_audioSource.loop = this.currentSound.isLoop; this.fadeA_audioSource.pitch = this.currentSound.pitch; this.fadeA_audioSource.dopplerLevel = this.currentSound.dopplerLevel; this.fadeA_audioSource.rolloffMode = this.currentSound.rollOffMode; this.fadeA_audioSource.minDistance = this.currentSound.minDistance; this.fadeA_audioSource.maxDistance = this.currentSound.maxDistance; this.fadeA_audioSource.spatialBlend = this.currentSound.spatialBlend; this.currentSound.FadeIn(time, ease); this.fadeA_audioSource.Play(); this.currentPlayingType = MusicPlayingType.SourceA; if (this.currentSound.HasLoop()) { this.isTicking = true; DoTick(); } } }
//BGM STOP public void BGMStop(bool _allStop = false) { if (_allStop == true) { fadeA_audio.Stop(); fadeB_audio.Stop(); } FadeOut(0.5f, Interpolate.EaseType.Linear); currentPlayingType = MusicPlayingType.None; isTicking = false; StopAllCoroutines(); }
/// <summary> /// 중지. /// </summary> public void Stop(bool allStop = false) { if (allStop == true) { this.fadeA_audioSource.Stop(); this.fadeB_audioSource.Stop(); } this.FadeOut(0.5f, Interpolate.EaseType.Linear); this.currentPlayingType = MusicPlayingType.None; this.isTicking = false; }
public void Stop(bool allStop = false) { if (allStop) { this.fadeA_audio.Stop(); this.fadeB_audio.Stop(); } this.FadeOut(0.5f, Interpolate.EaseType.Linear); this.currentPlayingType = MusicPlayingType.None; StopAllCoroutines(); }
private void Update() { if (currentSound == null) { return; } switch (currentPlayingType) { case MusicPlayingType.None: break; case MusicPlayingType.SourceA: currentSound.DoFade(Time.deltaTime, fadeA_audio); break; case MusicPlayingType.SourceB: currentSound.DoFade(Time.deltaTime, fadeB_audio); break; case MusicPlayingType.AtoB: lastSound.DoFade(Time.deltaTime, fadeA_audio); currentSound.DoFade(Time.deltaTime, fadeB_audio); break; case MusicPlayingType.BtoA: lastSound.DoFade(Time.deltaTime, fadeB_audio); currentSound.DoFade(Time.deltaTime, fadeA_audio); break; } if (fadeA_audio.isPlaying == true && fadeB_audio.isPlaying == false) { currentPlayingType = MusicPlayingType.SourceA; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == true) { currentPlayingType = MusicPlayingType.SourceB; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == false) { currentPlayingType = MusicPlayingType.None; } }
//Interpolate.EaseType easeType 보간 곡선 /// <summary> /// clip을 주어지는 time과 ease로 FadeIn /// </summary> public void FadeIn(SoundClip clip, float time, Interpolate.EaseType ease) { if (this.IsDifferentSound(clip)) //다른 사운드가 맞다면 { fadeA_audio.Stop(); fadeB_audio.Stop(); this.lastSound = this.currentSound; this.currentSound = clip; PlayAudioSource(fadeA_audio, currentSound, 0.0f); this.currentSound.FadeIn(time, ease); this.currentPlayingType = MusicPlayingType.SourceA; if (this.currentSound.HasLoop()) { this.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(); } } }
/// <summary> /// 배경음 사운드 재생. /// </summary> public void Play(SoundClip m) { if (this.CheckPlay(m)) { this.fadeB_audioSource.Stop(); this.lastSound = this.currentSound; this.currentSound = m; PlayAudioSource(this.fadeA_audioSource, m); this.currentPlayingType = MusicPlayingType.SourceA; if (this.currentSound.HasLoop()) { this.isTicking = true; DoTick(); } } }
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(); } } }
public void FadeTo(SoundClip clip, float time, Interpolate.EaseType ease) { if (this.currentPlayingType == MusicPlayingType.None) { this.FadeIn(clip, time, ease); } else if (this.IsDifferentSound(clip) == true) { if (this.currentPlayingType == MusicPlayingType.AtoB) { this.fadeA_audio.Stop(); this.currentPlayingType = MusicPlayingType.SourceB; } else if (this.currentPlayingType == MusicPlayingType.BtoA) { this.fadeB_audio.Stop(); this.currentPlayingType = MusicPlayingType.SourceA; } //fade to this.lastSound = this.currentSound; this.currentSound = clip; this.lastSound.FadeOut(time, ease); this.currentSound.FadeIn(time, ease); if (this.currentPlayingType == MusicPlayingType.SourceA) { PlayAudioSource(fadeB_audio, this.currentSound, 0.0f); this.currentPlayingType = MusicPlayingType.AtoB; } else if (this.currentPlayingType == MusicPlayingType.SourceB) { PlayAudioSource(fadeA_audio, this.currentSound, 0.0f); this.currentPlayingType = MusicPlayingType.BtoA; } if (this.currentSound.HasLoop()) { this.isTicking = true; DoCheck(); } } }
private void Update() { if (this.currentSound == null) { return; } switch (this.currentPlayingType) { case MusicPlayingType.SourceA: this.currentSound.DoFade(Time.deltaTime, this.fadeA_audio); break; case MusicPlayingType.SourceB: this.currentSound.DoFade(Time.deltaTime, this.fadeB_audio); break; case MusicPlayingType.AtoB: this.lastSound.DoFade(Time.deltaTime, this.fadeA_audio); this.currentSound.DoFade(Time.deltaTime, this.fadeB_audio); break; case MusicPlayingType.BtoA: this.lastSound.DoFade(Time.deltaTime, this.fadeB_audio); this.currentSound.DoFade(Time.deltaTime, this.fadeA_audio); break; } if (this.fadeA_audio.isPlaying == true && this.fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceA; } else if (this.fadeB_audio.isPlaying == true && this.fadeA_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceB; } else if (this.fadeA_audio.isPlaying == true && this.fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.None; } }
/// <summary> /// /// </summary> private void Update() { if (this.currentSound == null) { return; } if (this.currentPlayingType == MusicPlayingType.SourceA) { this.currentSound.DoFade(Time.deltaTime, this.fadeA_audioSource); } else if (this.currentPlayingType == MusicPlayingType.SourceB) { this.currentSound.DoFade(Time.deltaTime, this.fadeB_audioSource); } else if (this.currentPlayingType == MusicPlayingType.AtoB) { this.lastSound.DoFade(Time.deltaTime, this.fadeA_audioSource); this.currentSound.DoFade(Time.deltaTime, this.fadeB_audioSource); } else if (this.currentPlayingType == MusicPlayingType.BtoA) { this.lastSound.DoFade(Time.deltaTime, this.fadeB_audioSource); this.currentSound.DoFade(Time.deltaTime, this.fadeA_audioSource); } if (this.fadeA_audioSource.isPlaying && !this.fadeB_audioSource.isPlaying) { this.currentPlayingType = MusicPlayingType.SourceA; } else if (this.fadeB_audioSource.isPlaying && !this.fadeA_audioSource.isPlaying) { this.currentPlayingType = MusicPlayingType.SourceB; } else if (!this.fadeA_audioSource.isPlaying && !this.fadeB_audioSource.isPlaying) { this.currentPlayingType = MusicPlayingType.None; } }
// Update is called once per frame void Update() { if (currentSound == null) { return; } if (currentPlayingType == MusicPlayingType.SourceA) { currentSound.DoFade(Time.deltaTime, fadeA_audio); } else if (currentPlayingType == MusicPlayingType.SourceB) { currentSound.DoFade(Time.deltaTime, fadeB_audio); } else if (currentPlayingType == MusicPlayingType.AtoB) { this.lastSound.DoFade(Time.deltaTime, fadeA_audio); this.currentSound.DoFade(Time.deltaTime, fadeB_audio); } else if (currentPlayingType == MusicPlayingType.BtoA) { this.lastSound.DoFade(Time.deltaTime, fadeB_audio); this.currentSound.DoFade(Time.deltaTime, fadeA_audio); } if (fadeA_audio.isPlaying && this.fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceA; } else if (fadeB_audio.isPlaying && fadeA_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceB; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.None; } }