private IEnumerator PlayAsync(float delay) { if (Source) { Source.Stop(); Source = null; IsPlaying = false; } IsPlaying = true; if (delay > 0) { yield return(new WaitForSeconds(delay)); } Source = Audio2DListener.GetNext(); Source.loop = Loop; Source.pitch = Pitch; Source.volume = Volume * AudioManager.GetVolume(Layer); Source.clip = Clip; while (Source != null && Source.isPlaying) { yield return(1); } Source = null; IsPlaying = false; }
/// <summary> /// Plays the Audio /// </summary> /// <param name="c">clip</param> /// <param name="v">volume</param> /// <param name="p">pitch</param> /// <param name="l">Audio ayer</param> /// <returns>A playing audio source</returns> public static AudioSource Play(AudioClip c, float v, float p, AudioLayer l) { var s = GetNext(); // return null if (s == null) { return(null); } s.clip = c; s.pitch = p; s.loop = false; s.volume = v * AudioManager.GetVolume(l); s.Play(); return(s); }
public void UpdateVolume() { Audio.volume = LocalVolume * AudioManager.GetVolume(Layer); }