/// <summary> /// Used by AudioSourceWrappers. /// </summary> /// <param name="source"></param> public void OnAudioStarted(AudioSourceWrapper source) { if (!playingAudio.Contains(source)) { playingAudio.Add(source); } }
public IAudioSource PlayLearningBlock(string AudioFile, System.Action callback, bool clearPreviousCallback = false) { if (clearPreviousCallback) { dialogueEndedCallbacks.Clear(); } if (!string.IsNullOrEmpty(AudioFile)) { AudioClip clip = GetLearningBlockAudioClip(AudioFile); var wrapper = new AudioSourceWrapper(dialogueGroup.Play(clip), dialogueGroup, this); if (callback != null) { dialogueEndedCallbacks[wrapper] = callback; } return(wrapper); } else { if (callback != null) { callback(); } } return(null); }
public IAudioSource PlayDialogue(LocalizationData data, System.Action callback, bool clearPreviousCallback = false) { if (clearPreviousCallback) { dialogueEndedCallbacks.Clear(); } if (!string.IsNullOrEmpty(LocalizationManager.GetLocalizedAudioFileName(data.Id))) { AudioClip clip = GetAudioClip(data); var wrapper = new AudioSourceWrapper(dialogueGroup.Play(clip), dialogueGroup, this); if (callback != null) { dialogueEndedCallbacks[wrapper] = callback; } return(wrapper); } else { if (callback != null) { callback(); } } return(null); }
/// <summary> /// Play a soundFX /// </summary> /// <param name="sfx">Sfx.</param> public IAudioSource PlaySound(Sfx sfx) { AudioClip clip = GetAudioClip(sfx); var source = new AudioSourceWrapper(sfxGroup.Play(clip), sfxGroup, this); var conf = GetConfiguration(sfx); if (conf != null) { source.Pitch = 1 + ((UnityEngine.Random.value - 0.5f) * conf.randomPitchOffset) * 2; source.Volume = conf.volume; } return(source); }