示例#1
0
    void StopAudio()
    {
        if (m_AudioPlayer.isPlaying)
        {
            m_AudioPlayer.Stop();
            m_AudioPlayer.clip = null;
        }

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
        if (UAP_AccessibilityManager.UseWindowsTTS())
        {
            WindowsTTS.Stop();
        }
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR) && !UNITY_WEBPLAYER
        if (UAP_AccessibilityManager.UseMacOSTTS())
        {
            MacOSTTS.instance.Stop();
        }
#elif UNITY_ANDROID
        if (UAP_AccessibilityManager.UseAndroidTTS())
        {
            m_TTS_SpeakingTimer = 0.0f;
            AndroidTTS.StopSpeaking();
        }
#elif UNITY_IOS
        if (UAP_AccessibilityManager.UseiOSTTS())
        {
            m_TTS_SpeakingTimer = 0.0f;
            iOSTTS.StopSpeaking();
        }
#endif
    }
    void StopAudio(bool includingAndroid = false)
    {
        if (m_AudioPlayer.isPlaying)
        {
            m_AudioPlayer.Stop();
            m_AudioPlayer.clip = null;
        }

        if (UAP_CustomTTS.IsInitialized() == UAP_CustomTTS.TTSInitializationState.NotInitialized)
        {
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (UAP_AccessibilityManager.UseWindowsTTS() && WindowsTTS.instance != null)
            {
                WindowsTTS.Stop();
            }
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR) && !UNITY_WEBPLAYER
            if (UAP_AccessibilityManager.UseMacOSTTS())
            {
                MacOSTTS.instance.Stop();
            }
#elif UNITY_ANDROID
            if (UAP_AccessibilityManager.UseAndroidTTS())
            {
                m_TTS_SpeakingTimer = 0.0f;
                if (includingAndroid)
                {
                    AndroidTTS.StopSpeaking();
                }
            }
#elif UNITY_IOS
            if (UAP_AccessibilityManager.UseiOSTTS())
            {
                m_TTS_SpeakingTimer = 0.0f;
                iOSTTS.StopSpeaking();
            }
#endif
        }
        else
        {
            UAP_CustomTTS.Stop();
        }
    }