public void Play(string streamName, AssetFile file, float volume, bool isLoop, float fadeTime, bool isReplay, Func <float> callbackMasterVolume) { bool isStreaming = (file.LoadFlags & AssetFileLoadFlags.Streaming) == AssetFileLoadFlags.Streaming; SoundStream stream = PlaySub(streamName, file.Sound, volume, isLoop, isStreaming, fadeTime, isReplay, callbackMasterVolume); file.AddReferenceComponet(stream.gameObject); }
public void Play(string streamName, AssetFile file, float volume, bool isLoop, float fadeInTime, float fadeOutTime, bool isReplay, Func <float> callbackMasterVolume) { if (file.Sound == null) { Debug.LogError("sound file is not loaded " + file.FileName); return; } bool isStreaming = (file.LoadFlags & AssetFileLoadFlags.Streaming) == AssetFileLoadFlags.Streaming; SoundStream stream = PlaySub(streamName, file.Sound, volume, isLoop, isStreaming, fadeInTime, fadeOutTime, isReplay, callbackMasterVolume); file.AddReferenceComponet(stream.gameObject); }
/// <summary> /// サウンドの再生 /// </summary> /// <param name="type">サウンドのタイプ</param> /// <param name="file">サウンドファイル</param> /// <param name="isLoop">ループ再生するか</param> /// <param name="fadeTime">フェード時間</param> /// <param name="isReplay">直前が同じサウンドなら鳴らしなおすか</param> /// <returns>再生をしているサウンドストリーム</returns> public void Play(StreamType type, AssetFile file, bool isLoop, float fadeTime, bool isReplay) { if (!isReplay && IsPlaying(type, file.Sound)) { } else { SoundStream stream = Play(type, file.Sound, fadeTime, defaultVolume, isLoop, (file.LoadFlags & AssetFileLoadFlags.Streaming) == AssetFileLoadFlags.Streaming); if (null != stream) { file.AddReferenceComponet(stream.gameObject); } } }
void Update() { if (null != current) { current.Update(); } if (null != next) { if (next.IsReady() && current == null) { current = next; current.Play(); next = null; } } }
//指定のファイル名をロードして鳴らす IEnumerator CoLoadAndPlayFile(string path, float volume, bool isLoop, bool isStreaming, Func <float> callbackMasterVolume) { if (!string.IsNullOrEmpty(path)) { AssetFile file = AssetFileManager.GetFileCreateIfMissing(path); if (isStreaming) { file.AddLoadFlag(AssetFileLoadFlags.Streaming); } AssetFileManager.Load(file, this); while (!file.IsLoadEnd) { yield return(0); } SoundStream stream = Play(file.Sound, 0.1f, 0.1f, volume, isLoop, isStreaming, callbackMasterVolume); file.AddReferenceComponet(stream.gameObject); file.Unuse(this); } isLoading = false; }
internal SoundStream Play(AudioClip clip, float fadeTime, float volume, bool isLoop, bool isStreaming, Func<float> callbackMasterVolume, Action callbackEnd) { if (null != last) GameObject.Destroy(last.gameObject); if (null == current) { current = UtageToolKit.AddChildGameObjectComponent<SoundStream>(this.transform, clip.name); //即時再生 current.Play(clip, volume, isLoop, isStreaming, callbackMasterVolume, callbackEnd); return current; } else { //フェードアウト後に再生 last = current; last.FadeOut(fadeTime); current = UtageToolKit.AddChildGameObjectComponent<SoundStream>(this.transform, clip.name); current.Ready(clip, volume, isLoop, isStreaming, callbackMasterVolume, callbackEnd); return current; } }
internal SoundStream Play(AudioClip clip, float fadeTime, float masterVolume, float volume, bool isLoop, bool isStreaming, Action callBackEnd) { if (null != next) { GameObject.Destroy(next.gameObject); } if (null == current) { current = UtageToolKit.AddChildGameObjectComponent <SoundStream>(this.transform, clip.name); //即時再生 current.Play(clip, masterVolume, volume, isLoop, isStreaming, callBackEnd); return(current); } else { //フェードアウト後に再生 current.FadeOut(fadeTime); next = UtageToolKit.AddChildGameObjectComponent <SoundStream>(this.transform, clip.name); next.Ready(clip, masterVolume, volume, isLoop, isStreaming, callBackEnd); return(next); } }