示例#1
0
 public void PlayMusic(Music music)
 {
     if (musicDictionary.TryGetValue(music, out AudioClip audioClip))
     {
         EazySoundManager.GetMusicAudio(EazySoundManager.PrepareMusic(audioClip)).Play();
     }
 }
    private void PlaySoundAudio(MAudio mAudio, bool loop)
    {
        _soundId = EazySoundManager.PrepareMusic(
            mAudio.AudioClip,
            0.2f,
            loop,
            false
            );
        Audio audio = EazySoundManager.GetAudio(_soundId.Value);

        audio.Play();
    }
    private Audio PlayAmbientAudio(MAudio mAudio, bool loop, bool loadMany = false)
    {
        ClearAmbientQueue();
        _ambientMusicId = EazySoundManager.PrepareMusic(
            loadMany ? mAudio.AudioClips[mAudio.GetRandomIndex()] : mAudio.AudioClip,
            0.2f,
            loop,
            false
            );
        Audio audio = EazySoundManager.GetAudio(_ambientMusicId.Value);

        audio.Play();
        return(audio);
    }
    public void PlayBackgroundMusic(string musicName, bool loop = true, float?time = null)
    {
        Audio audio;

        if (_backgroundMusicId.HasValue)
        {
            audio = EazySoundManager.GetAudio(_backgroundMusicId.Value);
            audio.Stop();
        }
        _backgroundMusicId = EazySoundManager.PrepareMusic(Sounds[musicName].AudioClip, 0.7f, loop, false);
        _backgroundMusic   = musicName;
        audio = EazySoundManager.GetAudio(_backgroundMusicId.Value);
        audio.Play();
        if (time.HasValue)
        {
            audio.AudioSource.time = time.Value;
        }
    }