Example #1
0
        void PlaySub(float fadeInTime)
        {
            float volume = GetVolume();

            AudioSource.clip = Data.Clip;
            if (Data.EnableIntroLoop)
            {
                Audio1.clip   = Data.Clip;
                Audio1.volume = volume;
            }

            if (fadeInTime > 0)
            {
                status = SoundStreamStatus.FadeIn;
                fadeValue.Init(fadeInTime, fadeValue.GetValue(), 1);
            }
            else
            {
                status = SoundStreamStatus.Play;
                fadeValue.Init(0, 1, 1);
            }

            AudioSource.volume = volume;
            if (Data.EnableIntroLoop)
            {
                //イントロループする場合はPlayだとズレるので、PlayScheduledで正確に
                //ただしちょっと遅らせる必要あり
                const float IntroDelay = 0.1f;
                AudioSource.PlayScheduled(AudioSettings.dspTime + IntroDelay);
            }
            else
            {
                AudioSource.Play();
            }
        }
Example #2
0
 //フェードイン処理
 void UpdateFadeIn()
 {
     fadeValue.IncTime();
     if (fadeValue.IsEnd())
     {
         status = SoundStreamStatus.Play;
     }
 }
Example #3
0
 //フェードイン処理
 void UpdateFadeIn()
 {
     fadeInValue.IncTime();
     audioSource.volume = fadeInValue.GetValue() * requestVolume * masterVolume;
     if (fadeInValue.IsEnd())
     {
         status = SoundStreamStatus.Play;
     }
 }
Example #4
0
 /// <summary>
 /// 再生するための準備
 /// </summary>
 /// <param name="clip">オーディクリップ</param>
 /// <param name="masterVolume">マスターボリューム</param>
 /// <param name="volume">再生ボリューム</param>
 /// <param name="isLoop">ループ再生するか</param>
 /// <param name="isStreaming">ストリーム再生するか</param>
 /// <param name="callBackEnd">再生終了時に呼ばれるコールバック</param>
 public void Ready(AudioClip clip, float masterVolume, float volume, bool isLoop, bool isStreaming, Action callBackEnd)
 {
     this.clip          = clip;
     this.masterVolume  = masterVolume;
     this.requestVolume = volume;
     this.isLoop        = isLoop;
     this.isStreaming   = isStreaming;
     this.CallBackEnd   = callBackEnd;
     status             = SoundStreamStatus.Ready;
 }
Example #5
0
 /// <summary>
 /// 再生するための準備
 /// </summary>
 /// <param name="clip">オーディクリップ</param>
 /// <param name="masterVolume">マスターボリューム</param>
 /// <param name="volume">再生ボリューム</param>
 /// <param name="isLoop">ループ再生するか</param>
 /// <param name="isStreaming">ストリーム再生するか</param>
 /// <param name="callBackEnd">再生終了時に呼ばれるコールバック</param>
 public void Ready(AudioClip clip, float fadeInTime, float volume, bool isLoop, bool isStreaming, Func <float> callbackMasterVolume, Action callbackEnd)
 {
     this.clip                 = clip;
     this.fadeInTime           = fadeInTime;
     this.requestVolume        = volume;
     this.isLoop               = isLoop;
     this.isStreaming          = isStreaming;
     this.callbackMasterVolume = callbackMasterVolume;
     this.callbackEnd          = callbackEnd;
     status = SoundStreamStatus.Ready;
 }
Example #6
0
 //指定時間フェードアウトして終了
 public void FadeOut(float fadeTime)
 {
     if (fadeTime > 0 && IsPlaying())
     {
         status = SoundStreamStatus.FadeOut;
         fadeValue.Init(fadeTime, fadeValue.GetValue(), 0);
     }
     else
     {
         EndFadeOut();
     }
 }
Example #7
0
 /// <summary>
 /// 再生
 /// </summary>
 public void Play()
 {
     if (!clip.isReadyToPlay)
     {
         Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.SoundNotReadyToPlay, clip.name));
     }
     audioSource.clip   = clip;
     audioSource.loop   = IsLoop;
     audioSource.volume = requestVolume * masterVolume;
     audioSource.Play();
     status = SoundStreamStatus.Play;
 }
 /// <summary>
 /// 再生
 /// </summary>
 public void Play()
 {
     if (!WrapperUnityVersion.IsReadyPlayAudioClip(clip))
     {
         Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.SoundNotReadyToPlay, clip.name));
     }
     audioSource.clip   = clip;
     audioSource.loop   = IsLoop;
     audioSource.volume = requestVolume * callbackMasterVolume();
     audioSource.Play();
     status = SoundStreamStatus.Play;
 }
        //指定時間フェードイン
        internal void FadeIn(float fadeTime)
        {
            Play();
            float volume = 0;

            if (status == SoundStreamStatus.FadeOut)
            {
                volume = fadeOutValue.GetValue();
            }
            status = SoundStreamStatus.FadeIn;
            fadeInValue.Init(fadeTime, 1, volume);
        }
Example #10
0
 //指定時間フェードアウトして終了
 public void FadeOut(float fadeTime)
 {
     CancelInvoke();
     if (fadeTime > 0 && !IsEnd())
     {
         status = SoundStreamStatus.FadeOut;
         fadeOutValue.Init(fadeTime, 1, 0);
     }
     else
     {
         End();
     }
 }
Example #11
0
/*
 *              //指定時間フェードイン
 *              internal void FadeIn(float fadeTime)
 *              {
 *                      Play();
 *                      float volume = 0;
 *                      if (status == SoundStreamStatus.FadeOut)
 *                      {
 *                              volume = fadeOutValue.GetValue();
 *                      }
 *                      status = SoundStreamStatus.FadeIn;
 *                      fadeInValue.Init(fadeTime, 1, volume);
 *              }
 */

        //指定時間フェードアウトして終了
        public void FadeOut(float fadeTime)
        {
            CancelInvoke();
            if (fadeTime > 0 && !IsEnd())
            {
                float volume = 1;
                if (status == SoundStreamStatus.FadeIn)
                {
                    volume = fadeOutValue.GetValue();
                }
                status = SoundStreamStatus.FadeOut;
                fadeOutValue.Init(fadeTime, volume, 0);
            }
            else
            {
                End();
            }
        }
Example #12
0
 IEnumerator CoWaitDelay(float fadeInTime, float delay)
 {
     status    = SoundStreamStatus.Delay;
     IsLoading = (Data.File != null && !Data.File.IsLoadEnd);
     if (IsLoading)
     {
         AssetFileManager.Load(Data.File, this);
     }
     if (delay > 0)
     {
         yield return(new WaitForSecondsRealtime(delay));
     }
     if (IsLoading)
     {
         while (!Data.File.IsLoadEnd)
         {
             yield return(null);
         }
         Data.File.Unuse(this);
     }
     IsLoading = false;
     PlaySub(fadeInTime);
 }
Example #13
0
        /// <summary>
        /// 再生
        /// </summary>
        public void Play()
        {
/*			if (!WrapperUnityVersion.IsReadyPlayAudioClip(clip))
 *                      {
 *                              Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.SoundNotReadyToPlay,clip.name));
 *                      }*/
            audioSource.clip   = clip;
            audioSource.loop   = IsLoop;
            audioSource.volume = requestVolume * callbackMasterVolume();
            audioSource.Play();
            status = SoundStreamStatus.Play;

            if (fadeInTime > 0)
            {
                float volume = 0;
                if (status == SoundStreamStatus.FadeOut)
                {
                    volume = fadeOutValue.GetValue();
                }
                status = SoundStreamStatus.FadeIn;
                fadeInValue.Init(fadeInTime, volume, 1);
            }
        }
		/// <summary>
		/// 再生するための準備
		/// </summary>
		/// <param name="clip">オーディクリップ</param>
		/// <param name="masterVolume">マスターボリューム</param>
		/// <param name="volume">再生ボリューム</param>
		/// <param name="isLoop">ループ再生するか</param>
		/// <param name="isStreaming">ストリーム再生するか</param>
		/// <param name="callBackEnd">再生終了時に呼ばれるコールバック</param>
		public void Ready(AudioClip clip, float volume, bool isLoop, bool isStreaming, Func<float> callbackMasterVolume, Action callbackEnd)
		{
			this.clip = clip;
			this.requestVolume = volume;
			this.isLoop = isLoop;
			this.isStreaming = isStreaming;
			this.callbackMasterVolume = callbackMasterVolume;
			this.callbackEnd = callbackEnd;
			status = SoundStreamStatus.Ready;
		}
		//フェードイン処理
		void UpdateFadeIn()
		{
			fadeInValue.IncTime();
			audioSource.volume = fadeInValue.GetValue() * requestVolume * callbackMasterVolume();
			if (fadeInValue.IsEnd())
			{
				status = SoundStreamStatus.Play;
			}
		}
		//指定時間フェードアウトして終了
		public void FadeOut(float fadeTime)
		{
			CancelInvoke();
			if (fadeTime > 0 && !IsEnd())
			{
				float volume = 1;
				if (status == SoundStreamStatus.FadeIn)
				{
					volume = fadeOutValue.GetValue();
				}
				status = SoundStreamStatus.FadeOut;
				fadeOutValue.Init(fadeTime, volume, 0);
			}
			else
			{
				End();
			}
		}
		//指定時間フェードイン
		internal void FadeIn(float fadeTime)
		{
			Play();
			float volume = 0;
			if (status == SoundStreamStatus.FadeOut)
			{
				volume = fadeOutValue.GetValue();
			}
			status = SoundStreamStatus.FadeIn;
			fadeInValue.Init(fadeTime, 1, volume);
		}
		/// <summary>
		/// 再生
		/// </summary>
		public void Play()
		{
			if (!WrapperUnityVersion.IsReadyPlayAudioClip(clip))
			{
				Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.SoundNotReadyToPlay,clip.name));
			}
			audioSource.clip = clip;
			audioSource.loop = IsLoop;
			audioSource.volume = requestVolume * callbackMasterVolume();
			audioSource.Play();
			status = SoundStreamStatus.Play;
		}