private EffectController CreateEffect(string effectName) { //创建特效 //TODO:RES EffectController effect = null; foreach (var item in effects) { if (item.effectName == effectName) { effect = item; break; } } GameObject clone = ClonePrefab(string.Format("resources/prefabs/effect/{0}.unity3d", effectName), effectName); if (clone != null) { effect = clone.GetComponent <EffectController>(); effect.transform.SetParent(worldRoot); effect.transform.SetUnused(false, effectName); } return(effect); }
public void ReturnEffect(EffectController effect) { if (effect != null) { effect.transform.SetParent(worldRoot); effect.transform.SetUnused(false, effect.effectName); effectDic[effect.effectName.ToLower()].Return(effect); } }
//快速创建一个在世界位置播放的定时回收特效 public EffectController CreateWorldPositionEffect(string effectName, Vector3 worldPosition) { EffectController effect = CreateEffectByName <EffectController>(effectName, EffectPlayType.WorldPosition); if (effect != null) { effect.transform.position = worldPosition; effect.Play(); } return(effect); }
//移除特效 public void RemoveEffect(EffectController effect) { if (effect == null) { return; } //不做判断直接从列表中移除 effectList.Remove(effect); //避免循环调用 if (effect.effectHolder != null && effect.effectHolder.Equals(this)) { effect.Return(); } }
//添加特效 public void AddEffect(EffectController effect) { if (effectNode == null) { UtilityHelper.LogError("Add effect failed. Node is null."); return; } if (effect != null) { effect.transform.SetParent(effectNode); effect.transform.Normalize(); effect.gameObject.SetActive(true); effect.effectHolder = this; effectList.Add(effect); } }