/// <summary> /// 播放音效可重叠播放(NGUI播放方式,只能一次播放完整才能销毁,最好不要使用) /// </summary> /// <param name="name"></param> public void PlayFxSoundOverlap(string name, bool isLoop = false) { if (fxClip == null) { return; } if (isPlayFxVolume) { for (int i = 0; i < fxClip.Length; i++) { if (name == fxClip[i].name) { //NGUITools.PlaySound(fxClipStatic[i], fxVolume); var gameObject = audioSpwan.Spawn("AudioShotGame", transform); var _audio = gameObject.GetComponent <AudioSource>(); _audio.clip = fxClip[i]; _audio.volume = fxVolume; _audio.loop = isLoop; _audio.Play(); AudioShot model = gameObject.GetComponent <AudioShot>(); if (string.IsNullOrEmpty(model.audioName)) { model.name = audioCount + ""; audioCount++; fxAudioList.Add(_audio); //添加到集合中 } return; } } } }
public void PlayMusicSoundOverlap(string name) { if (musicClip == null) { return; } if (isPlayMusicVolume) { for (int i = 0; i < musicClip.Length; i++) { if (name == musicClip[i].name) { var gameObject = audioSpwan.Spawn("AudioShotGame", this.transform); var _audio = gameObject.GetComponent <AudioSource>(); _audio.clip = fxClip[i]; _audio.volume = fxVolume; _audio.Play(); AudioShot model = gameObject.GetComponent <AudioShot>(); if (string.IsNullOrEmpty(model.audioName)) { model.audioName = audioCount + ""; audioCount++; //添加到集合中 musicAudioList.Add(_audio); } return; } } } }