private void PlayVoiceOver(String p_voiceAudioID) { if (m_currentAudioRequest != null && m_currentAudioRequest.IsLoading) { m_currentAudioRequest.AbortLoad(); } if (m_currentAudioObject != null) { if (m_currentAudioObject.IsPlaying()) { m_currentAudioObject.Stop(); } AudioManager.Instance.UnloadByAudioID(m_currentAudioObject.audioID); m_currentAudioObject = null; } if (!AudioManager.Instance.IsValidAudioID(p_voiceAudioID)) { Debug.LogError("Dialog: Unknow voice audioID '" + p_voiceAudioID + "'!"); return; } m_currentAudioRequest = AudioManager.Instance.RequestByAudioID(p_voiceAudioID, 100, delegate(AudioRequest a) { if (a.IsDone && a.Controller != null) { m_currentAudioObject = AudioController.Play(p_voiceAudioID); StopAllCoroutines(); StartCoroutine(UnloadVoiceOver()); } }); }
public void PlaySound(String audioID) { if (IsMuted) { return; } if (m_loopingSound != null) { if (m_loopingSound.audio.loop) { m_loopingSound.audio.loop = false; } else { StartCoroutine(StopLoopAfter(m_loopingSound.clipLength - m_loopingSound.audio.time + 0.3f, m_loopingSound)); m_loopingSound = null; } } if (!AudioManager.Instance.IsValidAudioID(audioID)) { Debug.LogError("AnimatorSoundEffects; PlaySound: AudioID '" + audioID + "' not found!", this); return; } if (AudioManager.Instance.InAudioRange(m_transform.position, audioID)) { if (AudioManager.Instance.IsAudioIDLoaded(audioID)) { AudioObject audioObject = AudioHelper.PlayWithProbabilityOfFirstItem(audioID, transform, 1f, 0f, 0f); if (audioObject != null && audioObject.audioItem.Loop != AudioItem.LoopMode.DoNotLoop) { m_loopingSound = audioObject; } } else { if (m_request != null && m_request.IsLoading) { if (m_request.CategoryName == AudioManager.Instance.FindCategoryNameByAudioID(audioID)) { return; } m_request.AbortLoad(); } m_request = AudioManager.Instance.RequestByAudioID(audioID, 5, delegate(AudioRequest a) { if (a.Controller != null) { AudioObject audioObject2 = AudioHelper.PlayWithProbabilityOfFirstItem(audioID, transform, 1f, 0f, 0f); if (audioObject2 != null && audioObject2.audioItem.Loop != AudioItem.LoopMode.DoNotLoop) { m_loopingSound = audioObject2; } } }); } } }
private void OnCloseKeyPressed(Object p_sender, HotkeyEventArgs p_args) { if (p_args.KeyDown && m_state.IsState(EState.ACTIVE)) { if (m_currentAudioRequest != null) { m_currentAudioRequest.AbortLoad(); } if (m_currentAudio != null) { m_currentAudio.Stop(); } m_state.ChangeState(EState.FADEOUT); } }