void SetAudio(Frame f) { foreach (var audio in f.aduioList) { AniResource.PlaySoundOnce(audio); } }
//管理生命周期 void CheckEffect() { //编辑器中误操作,移除所有为null的引用 for (int i = livetimelist.Count - 1; i >= 0; i--) { livetimelist[i].lifetime--; //生命周期每帧 -1 if (livetimelist[i].lifetime <= 0) //生命周期结束 删除特效 { AniResource.CloseEffectLooped(livetimelist[i].effid); livetimelist.RemoveAt(i); } } //Resources.UnloadUnusedAssets(); //GC.Collect(); }
public void Play(string clip, string subclip = null, float cross = 0.2f) { if (string.IsNullOrEmpty(clip) == false) { var _clip = GetClip(clip); if (_clip == null) { Debug.LogWarning("No clip:" + clip); return; } SubClip _subclip = null; if (string.IsNullOrEmpty(subclip) == false) { _subclip = _clip.GetSubClip(subclip); } //清除特效 if (!string.IsNullOrEmpty(curClipName)) { if (curClipName.Equals(clip)) { foreach (var i in livetimelist) { i.lifetime = 1000; } } else { for (int i = 0; i < livetimelist.Count - 1; i++) { AniResource.CloseEffectLooped(livetimelist[i].effid); livetimelist.RemoveAt(i); } AniResource.CleanAllEffect(); curClipName = clip; } } //Debug.LogError("_clip = " + _clip); Play(clip: _clip, clipsub: _subclip, crosstimer: cross); } }
//每帧检测 void SetEffect(Frame f) { CheckEffect(); foreach (var e in f.effectList) { Transform o = this.transform.Find(e.follow); if (e.lifeframe > 0) { if (o != null) { die d = new die(); d.lifetime = e.lifeframe; d.effid = AniResource.PlayEffectLooped(e.name, e.position, dir, o); livetimelist.Add(d); } } else { AniResource.PlayEffect(e.name, o, e.position, e.isFollow, dir); } } }