public static void Play(string keyName, float fadeTime = 0.6f) { Init(); if (currentAudioGroupData != null && keyName == currentAudioGroupData.keyName && audioGroupPlayState == AudioGroupPlayState.Playing) { return; } //Debug.Log("AudioGroupSystem.Play :" + keyName); audioGroupPlayState = AudioGroupPlayState.Playing; // Dictionary<int, AudioAsset> playingMusics = AudioPlayManager.a2DPlayer.bgMusicDic; if (currentAudioGroupData != null) { foreach (var item in currentAudioGroupData.fixedMusicDatas) { AudioPlayManager.StopMusic2D(item.channel, fadeTime); } foreach (var ss in currentAudioGroupData.loopMusicDatas) { foreach (var item in ss.musicDatas) { AudioPlayManager.StopMusic2D(item.channel, fadeTime); } } } currentAudioGroupData = audioGroupDataDic[keyName]; for (int i = 0; i < currentAudioGroupData.fixedMusicDatas.Count; i++) { MusicPlayData data = currentAudioGroupData.fixedMusicDatas[i]; PlayMusicData(data); } foreach (var item in currentAudioGroupData.fixedSFXDatas) { PlaySFXData(item); } instance.randomLoopSFXDatas.Clear(); foreach (var item in currentAudioGroupData.sFXRandomLoopDatas) { instance.randomLoopSFXDatas.Add(new RandomLoopSFXData(item)); } foreach (var item in instance.randomLoopMusicDatas) { item.Close(); } instance.randomLoopMusicDatas.Clear(); foreach (var item in currentAudioGroupData.loopMusicDatas) { instance.randomLoopMusicDatas.Add(new RandomLoopMusicData(item)); } }
public static void Pause(bool isPause, float fadeTime = 0.5f) { if (audioGroupPlayState == AudioGroupPlayState.Playing && isPause) { audioGroupPlayState = AudioGroupPlayState.Pause; } if (audioGroupPlayState == AudioGroupPlayState.Pause && !isPause) { audioGroupPlayState = AudioGroupPlayState.Playing; } for (int i = 0; i < currentAudioGroupData.fixedMusicDatas.Count; i++) { MusicPlayData data = currentAudioGroupData.fixedMusicDatas[i]; AudioPlayManager.PauseMusic2D(data.channel, isPause, fadeTime); } AudioPlayManager.PauseSFXAll2D(isPause); }
public static void Play(string keyName, float fadeTime = 0.6f) { Init(); if (currentAudioGroupData != null && keyName == currentAudioGroupData.keyName) { return; } audioGroupPlayState = AudioGroupPlayState.Playing; currentAudioGroupData = audioGroupDataDic[keyName]; Dictionary <int, AudioAsset> playingMusics = AudioPlayManager.a2DPlayer.bgMusicDic; foreach (var item in playingMusics) { if (item.Key > currentAudioGroupData.fixedMusicDatas.Count - 1) { AudioPlayManager.StopMusic2D(item.Key, fadeTime); } } for (int i = 0; i < currentAudioGroupData.fixedMusicDatas.Count; i++) { MusicPlayData data = currentAudioGroupData.fixedMusicDatas[i]; PlayMusicData(data); } foreach (var item in currentAudioGroupData.fixedSFXDatas) { PlaySFXData(item); } instance.randomLoopSFXDatas.Clear(); foreach (var item in currentAudioGroupData.sFXRandomLoopDatas) { instance.randomLoopSFXDatas.Add(AddLoopSFX(item)); } }