Ejemplo n.º 1
0
 public AudioClip GetSoundEvent(eSoundEvent soundEvent)
 {
     foreach (var sound in SoundEvents)
     {
         if (sound.Event == soundEvent)
         {
             return(sound.Audio);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
    public void PlaySound(AudioSource source, eSoundEvent soundEvent)
    {
        if (source == null)
        {
            return;
        }
        AudioClip clip = GetSoundEvent(soundEvent);

        if (clip == null)
        {
            Debug.LogError("No sound found for event: " + soundEvent.ToString());
            return;
        }
        source.clip = clip;
        source.Play();
    }