public void ShowEffect(string name, Vector3 worldPos, float lifeTime, Action callback) { GameObject effect = GameObjectPoolMgr.S.Allocate(name); effect.transform.SetParent(m_EffectRoot); effect.transform.position = worldPos; if (lifeTime < 0) { return; } UnityExtensions.CallWithDelay(GameplayMgr.S, () => { //todo :������нű��ǵ�reset,�����ÿ� if (effect == null)//effect��destroy { return; } ResetPartical(effect); GameObjectPoolMgr.S.Recycle(effect); if (callback != null) { callback.Invoke(); } }, lifeTime); }
private void DoShowUIEffect(string name, Transform root, int sortOrder, Vector3 worldPos, float lifeTime, Action callback) { GameObject effect = GameObjectPoolMgr.S.Allocate(name); effect.transform.SetParent(root); //effect.transform.localScale = Vector3.one; //set ui layer UnityExtensions.SetAllLayer(effect, LayerDefine.LAYER_UI); //set render order SetParticalRender(effect, sortOrder); effect.transform.position = worldPos; if (lifeTime < 0) { return; } UnityExtensions.CallWithDelay(GameplayMgr.S.Mono, () => { //todo :������нű��ǵ�reset,�����ÿ� if (effect == null) { return; } ResetPartical(effect); GameObjectPoolMgr.S.Recycle(effect); if (callback != null) { callback.Invoke(); } }, lifeTime); }
protected void PlayParticleSystem(GameObject p, Transform parent, Vector3 position, Quaternion rotation, float recycleTime, bool isUseSelfTime) { ParticleSystem ps = p.GetComponent <ParticleSystem>(); if (ps == null) { ps = p.GetComponentInChildren <ParticleSystem>(); } ps.Clear(); if (parent != null) { p.transform.SetParent(parent); } p.transform.position = position; p.transform.rotation = rotation; ps.Play(); if (isUseSelfTime) { recycleTime = ps.main.duration; } UnityExtensions.CallWithDelay(this, () => { GameObjectPoolMgr.S.Recycle(p.gameObject); }, recycleTime); }