Exemplo n.º 1
0
        public void Stop()
        {
            if (audioSource)
            {
                audioSource.Stop();
            }
            playState = AudioPlayState.Stop;

            if (sourceType == AudioSourceType.Music)
            {
                if (!isCallPreStop)
                {
                    isCallPreStop = true;
                    if (AudioPlayManager.OnMusicPreStopCallBack != null)
                    {
                        AudioPlayManager.OnMusicPreStopCallBack(AssetName, musicChannel, flag);
                    }
                }

                if (AudioPlayManager.OnMusicStopCallBack != null)
                {
                    AudioPlayManager.OnMusicStopCallBack(AssetName, musicChannel, flag);
                }
            }
            else
            {
                if (AudioPlayManager.OnSFXStopCallBack != null)
                {
                    AudioPlayManager.OnSFXStopCallBack(AssetName, flag);
                }
            }
        }
Exemplo n.º 2
0
        public static void Init()
        {
            GameObject       obj          = new GameObject("[AudioManager]");
            AudioPlayManager audioManager = obj.AddComponent <AudioPlayManager>();

            DontDestroyOnLoad(obj);

            a2DPlayer   = new Audio2DPlayer(audioManager);
            a3DPlayer   = new Audio3DPlayer(audioManager);
            TotleVolume = RecordManager.GetFloatRecord("GameSettingData", "TotleVolume", 1f);
            MusicVolume = RecordManager.GetFloatRecord("GameSettingData", "MusicVolume", 1f);
            SFXVolume   = RecordManager.GetFloatRecord("GameSettingData", "SFXVolume", 1f);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 检查音频是否播放完成
 /// </summary>
 public void CheckState()
 {
     if (playState == AudioPlayState.Stop)
     {
         return;
     }
     //Debug.Log("audioSource.time:" + audioSource.time + " clip.lenth:" + audioSource.clip.length);
     if (audioSource.clip.length > 1 && audioSource.time >= (audioSource.clip.length - 1) && !isCallPreStop)
     {
         isCallPreStop = true;
         if (AudioPlayManager.OnMusicPreStopCallBack != null)
         {
             AudioPlayManager.OnMusicPreStopCallBack(AssetName, musicChannel, flag);
         }
     }
     if (audioSource == null || (!audioSource.isPlaying && playState != AudioPlayState.Pause))
     {
         Stop();
     }
 }