Esempio n. 1
0
    // 스탑 사운드(일시정지인지)
    public void StopSound(bool isPause = false)
    {
        // Null체크
        if (BgmSpeaker == null)
        {
            Debug.Log("Speaker Null");
            return;
        }

        // 플레이 체크
        if (BgmSpeaker.isPlaying == false)
        {
            Debug.Log("Speaker Null Or Not Play Sound");
            return;
        }

        // Clip체크
        if (BgmSpeaker.clip == null)
        {
            Debug.Log("Empty Sound Clip");
            return;
        }

        // 사운드멈춤
        NowBgm = EBgmSound.None;
        BgmSpeaker.Stop();

        // 일시정지가 아니면 null처리
        if (isPause == false)
        {
            BgmSpeaker.clip = null;
        }
    }
Esempio n. 2
0
    // 플레이 사운드
    public void PlaySound(EBgmSound bgm, bool isLoop = true)
    {
        // 같은 타입 체크
        if (bgm == NowBgm)
        {
            Debug.Log("Same Sound Type:" + NowBgm.ToString());
            return;
        }

        // Null 체크
        if (BgmSpeaker == null)
        {
            Debug.Log("Speaker Null");
            return;
        }

        // 사운드 리스트 체크
        if (BgmSoundList == null || BgmSoundList.Count <= 0)
        {
            Debug.Log("Empty SoundList");
            return;
        }

        // 셋팅
        StopSound();
        NowBgm = bgm;

        // 사운드 찾아서 Play
        for (int i = 0; i < BgmSoundList.Count; i++)
        {
            if (BgmSoundList[i].SoundName == NowBgm)
            {
                BgmSpeaker.clip = BgmSoundList[i].SoundClip;
                BgmSpeaker.Play();
                BgmSpeaker.loop = isLoop;
            }
        }
    }