コード例 #1
0
ファイル: SoundController.cs プロジェクト: thaoabc/blockGame
    public void PlaySoundEffect(SoundInfor sound)
    {
        if (!IsSoundOn)
        {
            return;
        }

        AudioSource audioSource = GetAudioSource();

        audioSource.clip   = sound.Clip;
        audioSource.volume = sound.Volume;
        audioSource.Play();
    }
コード例 #2
0
ファイル: SoundController.cs プロジェクト: thaoabc/blockGame
    public void PlayBackgroundMusic(SoundInfor sound = null)
    {
        if (sound != null)
        {
            _curBackgroundMusic = sound;
        }

        if (IsMusicOn)
        {
            if (sound == null)
            {
                _backgroundSource.clip   = _curBackgroundMusic.Clip;
                _backgroundSource.volume = _curBackgroundMusic.Volume;
                _backgroundSource.Play();
            }
            else
            {
                _backgroundSource.clip   = sound.Clip;
                _backgroundSource.volume = sound.Volume;
                _backgroundSource.Play();
            }
        }
    }