/// <summary> /// Stops an Audio which is being played /// </summary> /// <param name="sound"></param> public void Stop(string sound) { EasyAudioUtility_Helper h = Array.Find(helper, item => item.name == sound); //Stopping h.source.Stop(); }
/// <summary> /// Play an Audio Clip defined in the inspector /// </summary> /// <param name="sound"></param> public void Play(string sound) { EasyAudioUtility_Helper h = Array.Find(helper, item => item.name == sound); //randomizing volume by variation h.source.volume = h.volume * (1f + UnityEngine.Random.Range(-h.volumeVariance / 2f, h.volumeVariance / 2f)); //randomizing pitch by variation h.source.pitch = h.pitch * (1f + UnityEngine.Random.Range(-h.pitchVariance / 2f, h.pitchVariance / 2f)); //playing it after setting all variations h.source.Play(); }
/// <summary> /// Play an Audio Clip defined in the inspector /// </summary> /// <param name="sound"></param> public void Play(Som som) { string sound = som.ToString(); EasyAudioUtility_Helper h = Array.Find(helper, item => item.name == sound); if (h != null) { //randomizing volume by variation h.source.volume = h.volume; //randomizing pitch by variation h.source.pitch = h.pitch; //playing it after setting all variations if (h.source.enabled) { h.source.Play(); } } }
public void AjustarSomBG(float volume) { EasyAudioUtility_Helper h = Array.Find(helper, item => item.name == Som.Background.ToString()); h.source.volume = volume * (1f + UnityEngine.Random.Range(-h.volumeVariance / 2f, h.volumeVariance / 2f)); }