Beispiel #1
0
        /// <summary>播放声音</summary>
        private void playSound(string soundName)
        {
            isPlay             = true;
            m_CurrentSoundName = soundName;

            progressSlider.interactable = false;

            downloadProgressSlider.value = 0;
            progressSlider.value         = 0;
            tiemText.text = "00/00";

            string[] tempArr       = m_CurrentSoundName.Split('/');
            string   tempSoundName = tempArr[tempArr.Length - 1];

            nameText.text = tempSoundName;

            if (m_Sound.Contains(m_CurrentSoundName))
            {
                downloadProgressSlider.value = 1;
                m_CurrentSundItem            = m_Sound.GetSoundItemByName(m_CurrentSoundName);
                if (m_CurrentSundItem != null && m_CurrentSundItem.state == SoundState.Pause)
                {
                    m_CurrentSundItem.ContinuePlay();
                }
                else
                {
                    m_Sound.PlaySound2D(m_CurrentSoundName, loopToggle.isOn, playProgress);
                }

                progressSlider.interactable = true;
                if (!string.IsNullOrEmpty(m_CurrentSoundName))
                {
                    m_Sound.SetLoop(m_CurrentSoundName, loopToggle.isOn);
                }
            }
            else
            {
                getAudioClip(m_CurrentSoundName);
            }

            updatePlayState();
        }