private void OnSoundLoaded(string filePath, object param = null) { StResPath stPath = (StResPath)param; string fileName = stPath.GetFileName(); //获取audio,并释放ab文件 AudioClip clip = ResDataManager.instance.CreateObjectFromCache <AudioClip>(filePath, true); if (clip != null) { SoundResLib.AddAudioClip(fileName, clip, stPath.tag); this.play(clip, this.getFreeAudioSource()); } }
public void PlaySkill(string soundName) { //静音不做处理 if (_isMute) { return; } AudioClip clip = SoundResLib.GetAudioClip(soundName); if (clip == null) { string localPath = "Sounds/skill/" + soundName; this.LoadSoundAssetBundle(localPath, ResTag.BattleSceneSound); } else { this.play(clip, this.getFreeAudioSource()); } }
public void Play(string bgmName) { this.Stop(); //静音不做处理 if (_isMute) { return; } AudioClip clip = SoundResLib.GetAudioClip(bgmName); if (clip == null) { string localPath = "Sounds/bgm/" + bgmName; this.LoadSoundAssetBundle(localPath, ResTag.BGM); } else { this.playBGM(clip); } }
/// <summary> /// 预加载完成 /// </summary> /// <param name="listName"></param> /// <param name="param"></param> private static void OnPreLoadSoundComplete(string listName, object param) { List <StResPath> soundsList = param as List <StResPath>; if (soundsList != null) { for (int i = 0; i < soundsList.Count; i++) { //获取audio,并释放ab文件 AudioClip clip = ResDataManager.instance.CreateObjectFromCache <AudioClip>(soundsList[i].path, true); if (clip != null) {//缓存 SoundResLib.AddAudioClip(soundsList[i].GetFileName(), clip, soundsList[i].tag); } } }//end if if (OnPreLoadSoundsEnd != null) { OnPreLoadSoundsEnd(); } }