示例#1
0
    private void StopBgmSound(BgmInfo bgmInfo)
    {
        var audioSource = audioSources[audioSourcesIndex];

        if (bgmInfo.fadeOutTime > 0)
        {
            DOTween.To(() => audioSource.volume, x => audioSource.volume = x, 0, bgmInfo.fadeOutTime)
            .OnComplete(() => {
                audioSource.Stop();
                audioSource.clip = null;
            });

            // 위와 같은 내용
            //audioSource.DOFade(0, bgmInfo.fadeOutTime).OnComplete(
            //    () => {
            //    audioSource.Stop();
            //    audioSource.clip = null;
            //});
        }
        else
        {
            audioSource.Stop();
            audioSource.clip = null;
        }
    }
示例#2
0
    /**
     *  @brief  BGM을 Smooth하게 변경한다
     *  @param  info : 변경할 배경음 정보
     */
    private IEnumerator BgmChangeEvent(BgmInfo info)
    {
        //현재 배경음 소리를 줄인다.
        if (audioSource.isPlaying)
        {
            while (audioSource.volume > 0)
            {
                audioSource.volume -= 0.01f;
                yield return(null);
            }
        }

        //배경음을 재생한다.
        BgmPlay(info);

        //배경음 소리를 올린다.
        while (true)
        {
            audioSource.volume += 0.01f;

            if (audioSource.volume >= 1)
            {
                audioSource.volume = 1;
                break;
            }

            yield return(null);
        }
    }
示例#3
0
    /**
     *  @brief  BGM 재생
     *  @param  info : 재생할 배경음 정보
     */
    public void BgmPlay(BgmInfo info)
    {
        BgmStop();

        audioSource.clip = info.clip;
        audioSource.Play();

        StartCoroutine(PrintBgmInfo(info));
    }
示例#4
0
    /**
     *  @brief  BGM 정보 출력
     *  @param  info : 출력할 배경음 정보
     */
    private IEnumerator PrintBgmInfo(BgmInfo info)
    {
        yield return(Yields.WaitSeconds(3.0f));

        string txt = "BGM INFO\n" +
                     "Artist : " + info.artist + "\n" +
                     "Title : " + info.title;

        NotifyMessageEvent.Instance.PrintSubText(txt);
    }
示例#5
0
    private void PlayBgmSound(BgmInfo bgm)
    {
        AudioSource audioSource = audioSources[audioSourcesIndex];

        audioSource.clip   = bgm.audioClip;
        audioSource.volume = bgm.volume;

        if (bgm.fadeInTime > 0)
        {
            audioSource.volume = bgm.fadeInBeginVolume;
            DOTween.To(() => audioSource.volume, x => audioSource.volume = x, bgm.volume, bgm.fadeInTime);
        }
        else
        {
            audioSource.volume = bgm.volume;
        }

        audioSource.Play();
    }
示例#6
0
 /**
  *  @brief  BGM 변경
  *  @param  info : 변경할 배경음 정보
  */
 public void BgmChange(BgmInfo info)
 {
     StartCoroutine(BgmChangeEvent(info));
 }