public void PlaySingle(SFXBANK id) { var clip = GetSFX(id); sfxSource.pitch = 1; if (clip != null) { PlaySingle(clip); } }
public void RandomizeSfx(SFXBANK id, float lowPitch, float highPitch) { //int randomIndex = Random.Range(0, clips.Length); float randomPitch = Random.Range(lowPitch, highPitch); sfxSource.pitch = randomPitch; var clip = GetSFX(id); if (clip != null) { sfxSource.PlayOneShot(clip); } }
public void PlaySingle(SFXBANK id, float pitch) { //sfxSource.clip = clip; //sfxSource.Play(); var clip = GetSFX(id); sfxSource.pitch = 1; if (clip != null) { sfxSource.pitch = pitch; sfxSource.PlayOneShot(clip); } }
// Helpers // Are these too slow to loop through all the time? Should it be a hash internally? public AudioClip GetSFX(SFXBANK id) { if (id == SFXBANK.NONE) { return(null); } for (int i = 0; i < SFXList.Count; i++) { if (id == SFXList[i].soundID) { return(SFXList[i].clip); } } Debug.LogError("SFX Clip not found for SFXBANK id: " + id + " Did you define it in the SoundManager?"); return(null); }