public void DeActivateEffect(Transform target) { if (target == null) { return; } target.SetParent(sleepParent); ZEffectBase effect = target.GetComponent <ZEffectBase>(); for (int i = 0; i < activedEffects.Count; i++) { if (activedEffects[i] == effect) { activedEffects.RemoveAt(i); break; } } if (effect != null) { effect.DeActive(); } else { target.gameObject.SetActive(false); } }
public GameObject GetEffectPrefab(long id) { EffectInfo model = GetEffectModel(id); if (model.id < 1) { return(null); } Transform target = GetPrefab <Transform>(model.bundle, model.assetPath, BundleType.Prefab_Effect); if (target != null) { ZEffectBase tool = target.GetComponent <ZEffectBase>(); if (tool == null) { tool = target.gameObject.AddComponent <ZEffectBase>(); } tool.lifeTime = model.lifeTime; tool.id = id; tool.isLoop = model.isLoop; tool.name = model.name; tool.type = model.type; return(target.gameObject); } return(null); }
public ZEffectBase ActivateEffect(long effectid, Transform parent, bool worldStay) { ZEffectBase effect = GetSleepEffect(effectid); if (effect == null) { effect = CreateEffect(effectid, parent, worldStay); } else { effect.mTransform.SetParent(parent, worldStay); } if (effect == null) { return(null); } if (worldStay == false) { effect.mTransform.localPosition = Vector3.zero; effect.mTransform.localRotation = Quaternion.identity; } effect.mTransform.localScale = Vector3.one; activedEffects.Add(effect); if (effect.gameObject.activeInHierarchy == false) { effect.gameObject.SetActive(true); } return(effect); }
private ZEffectBase GetSleepEffect(string uname) { for (int i = 0; i < effectList.Count; i++) { ZEffectBase tool = effectList[i]; if (tool != null && !tool.gameObject.activeInHierarchy && tool.label == uname) { return(tool); } } return(null); }
private ZEffectBase GetSleepEffect(long id) { for (int i = 0; i < effectList.Count; i++) { ZEffectBase tool = effectList[i]; if (tool != null && !tool.gameObject.activeInHierarchy && tool.id == id) { return(tool); } } return(null); }
private ZEffectBase CreateEffect(long effectid, Transform parent, bool worldStay) { GameObject prefab = GetEffectPrefab(effectid); if (prefab == null) { return(null); } ZEffectBase effect = CreateEffect(prefab, parent, worldStay); effect.id = effectid; return(effect); }
/// <summary> /// 播放特效 /// </summary> /// <param name="effectID"></param> /// <param name="parent"></param> /// <param name="locPosition"></param> /// <param name="locRotation"></param> /// <returns></returns> static public ZEffectBase PlayEffect(long effectID, Transform parent, bool worldStay) { if (effectID < 1) { return(null); } ZEffectBase effect = ZAssetController.Instance.ActivateEffect(effectID, parent, worldStay); if (effect != null) { effect.Play(); } return(effect); }
/// <summary> /// 播放特效 /// </summary> /// <param name="prefab"></param> /// <param name="life"></param> /// <param name="parent"></param> /// <param name="locPosition"></param> /// <param name="locRotation"></param> /// <returns></returns> static public ZEffectBase PlayEffect(GameObject prefab, float life, Transform parent, bool worldStay) { if (prefab == null) { return(null); } ZEffectBase effect = ZAssetController.Instance.ActivateEffect(prefab, parent, worldStay); if (effect != null) { effect.Play(life); } return(effect); }
public void RecoverEffect() { int leng = effectList.Count; for (int i = 0; i < leng; i++) { ZEffectBase tool = effectList[i]; if (tool != null && tool.gameObject.activeInHierarchy) { tool.transform.parent = sleepParent; tool.gameObject.SetActive(false); } } activedEffects.Clear(); }
private ZEffectBase CreateEffect(GameObject prefab, Transform parent, bool worldStay) { if (prefab == null) { return(null); } GameObject temp = Instantiate(prefab); temp.transform.SetParent(parent, worldStay); ZEffectBase tool = temp.GetComponent <ZEffectBase>(); if (tool == null) { tool = temp.AddComponent <ZEffectBase>(); } tool.label = prefab.name; temp.SetActive(false); effectList.Add(tool); return(tool); }