// SE再生 SoundSe PlaySeSub(AudioClip clip, float volume, string label, SoundPlayMode playMode) { //音量0なので、鳴らさない if (volume <= 0) { return(null); } //同一フレームで既に鳴っているので鳴らさない(多重再生防止) foreach (SoundSe audio in curretFrameSeList) { if (clip == audio.AudioSource.clip) { return(null); } } SoundSe se = PlaySeClip(clip, volume, label, playMode); if (se == null) { return(null); } curretFrameSeList.Add(se); seList.Add(se); return(se); }
//オーディオクリップをSEとして再生 SoundSe PlaySeClip(AudioClip clip, float volume, string label, SoundPlayMode playMode) { if (string.IsNullOrEmpty(label)) { label = clip.name; } switch (playMode) { case SoundPlayMode.Add: break; case SoundPlayMode.Cancel: if (IsPlayingSe(label)) { Debug.Log("Cancel"); StopSe(label, 0.02f); } break; case SoundPlayMode.NoPlay: if (IsPlayingSe(label)) { return(null); } break; } GameObject go = UtageToolKit.AddChild(CachedTransform, new GameObject(label)); SoundSe se = go.AddComponent <SoundSe>(); se.Init(clip, volume); return(se); }
public void PlaySe(AssetFile file, float volume, string label, SoundPlayMode playMode = SoundPlayMode.Add) { SoundSe audio = PlaySeSub(file.Sound, volume, label, playMode); if (audio) { file.AddReferenceComponet(audio.gameObject); } }