예제 #1
0
 protected void PlayMusicControl(AudioAsset au, string audioName, bool isLoop = true, float volumeScale = 1, float delay = 0f, float fadeTime = 0.5f)
 {
     if (au.assetName == audioName)
     {
         if (au.PlayState != AudioPlayState.Playing)
         {
             au.SetPlayState(AudioPlayState.Playing);
             AddFade(au, VolumeFadeType.FadeIn, fadeTime, delay, null, null);
             au.Play();
         }
     }
     else
     {
         AudioPlayState state = au.PlayState;
         au.SetPlayState(AudioPlayState.Playing);
         if (state == AudioPlayState.Playing)
         {
             AddFade(au, VolumeFadeType.FadeOut2In, fadeTime, delay, null, (value) =>
             {
                 PlayClip(value, audioName, isLoop, volumeScale, delay);
             });
         }
         else
         {
             PlayClip(au, audioName, isLoop, volumeScale, delay);
             AddFade(au, VolumeFadeType.FadeIn, fadeTime, delay, null, null);
         }
     }
 }
예제 #2
0
 protected void PauseMusicControl(AudioAsset au, bool isPause, float fadeTime = 0.5f)
 {
     if (isPause)
     {
         //Debug.Log("PauseMusicControl Pause : "+ au.PlayState);
         if (au.PlayState == AudioPlayState.Playing)
         {
             au.SetPlayState(AudioPlayState.Pause);
             //Debug.Log("PauseMusicControl Pause");
             AddFade(au, VolumeFadeType.FadeOut, fadeTime, 0, (value) =>
             {
                 //Debug.LogWarning("PauseMusicControl Pause fade CallBack");
                 value.Pause();
             }, null);
         }
     }
     else
     {
         //Debug.Log("PauseMusicControl play : "+ au.PlayState);
         if (au.PlayState == AudioPlayState.Pause)
         {
             //Debug.Log("PauseMusicControl play");
             au.SetPlayState(AudioPlayState.Playing);
             AddFade(au, VolumeFadeType.FadeIn, fadeTime, 0, null, null);
             au.Play();
         }
     }
 }
예제 #3
0
 protected void StopMusicControl(AudioAsset au, float fadeTime = 0.5f)
 {
     if (au.PlayState != AudioPlayState.Stop)
     {
         au.SetPlayState(AudioPlayState.Stoping);
         //Debug.Log ( $"StopMusicControl {fadeTime}" );
         AddFade(au, VolumeFadeType.FadeOut, fadeTime, 0, (value) =>
         {
             //Debug.LogWarning("StopMusicControl Stop fade CallBack");
             value.Stop();
         }, null);
     }
 }