/// <summary> /// Plays SFX from SFX channel with a callback appended at the end. /// </summary> /// <param name="audio"></param> /// <param name="vol"></param> /// <param name="pitch"></param> /// <param name="callback"></param> public void PlaySFX(AUDIOS audio, AUDIOPLAYER channel, Action callback, float vol = 1f, float pitch = 1f, float delay = 0.0f) { AudioClip audioClip; if (!audioMap.ContainsKey(audio)) { Debug.LogWarning(transform.gameObject.name + ": " + "Tried to play undefined sound: " + audio.ToString()); return; } channels[(int)channel].pitch = pitch; channels[(int)channel].volume = vol; if (audioMap.TryGetValue(audio, out audioClip)) { // channels[(int)AUDIOPLAYER.SFX].clip = audioClip; channels[(int)channel].PlayOneShot(audioClip); StartCoroutine(AppendSFXCallback(audioClip, delay, callback)); // channels[(int)AUDIOPLAYER.SFX].Play(); //if (channels[(int)AUDIOPLAYER.SFX].isPlaying) // Debug.Log("Playing: " + channels[(int)AUDIOPLAYER.SFX].clip.name); } }
//public void SetMusicVolume(float value) //{ // audioSettings[(int)AUDIOPLAYER.MUSIC].SetExposedParam(value); //} //public void SetSFXVolume(float value) //{ // audioSettings[(int)AUDIOPLAYER.SFX].SetExposedParam(value); //} public AudioSource GetChannel(AUDIOPLAYER player) { return(channels[(int)player]); }
/// <summary> /// Stops playing UISFX channel with a fade. /// </summary> /// <param name="duration"></param> public void StopUISFX(AUDIOPLAYER channel, float duration) { channels[(int)channel].DOFade(0.0f, duration).SetEase(Ease.OutQuad); }
/// <summary> /// Stops playing UISFX channel immediately. /// </summary> public void ImmediateStopUISFX(AUDIOPLAYER channel) { channels[(int)channel].Stop(); }