public static PlayMusicCompleteEventArgs Create(string assetName, float audioLength, object userData)
        {
            PlayMusicCompleteEventArgs playMusicCompleteEventArgs = ReferencePool.Acquire <PlayMusicCompleteEventArgs>();

            playMusicCompleteEventArgs.SoundAssetName = assetName;
            playMusicCompleteEventArgs.SoundLength    = audioLength;
            playMusicCompleteEventArgs.UserData       = userData;
            return(playMusicCompleteEventArgs);
        }
Beispiel #2
0
        bool CheckMusicComplete()
        {
            bool complete = false;

            if (!m_MusicSource.isPlaying)
            {
                // 音乐播放完毕  计时判断 误差1秒内都算结束
                if (Mathf.Abs(m_MusicTimer - m_MusicSource.clip.length) < 1)
                {
                    m_MusicTimer = 0;
                    if (m_EventManager != null)
                    {
                        m_EventManager.Fire(this, PlayMusicCompleteEventArgs.Create(m_MusicAssetName, m_MusicSource.clip.length, null));
                    }

                    complete = true;
                }
            }
            else
            {
                if (m_MusicSoundParams.Loop)
                {
                    if (m_MusicTimer > m_MusicSource.clip.length)
                    {
                        m_MusicTimer = 0;
                        if (m_EventManager != null)
                        {
                            m_EventManager.Fire(this, PlayMusicCompleteEventArgs.Create(m_MusicAssetName, m_MusicSource.clip.length, null));
                        }

                        complete = true;
                    }
                }
            }
            return(complete);
        }