public void PlaySound(string key, Vector3 position, SoundParams settings = null) { AudioSource source = sourcePool.Activate(position, Quaternion.identity, ResetAudioSource).GetComponent <AudioSource>(); AudioClip[] clips; bool hasClip = sounds.TryGetValue(key, out clips); if (hasClip) { if (settings != null) { source.volume = settings.volume; source.pitch = settings.pitch; } //Debug.Log("Playing sound on " + source.gameObject.name); AudioClip clip = clips[Random.Range(0, clips.Length)]; //Debug.Log(source); source.clip = clip; source.Play(); } else { Debug.LogWarning("Non-existant sound event \"" + key + "\""); } }