public void DestroyPrefabInstance(IManagedEffect effect)
 {
     if (effect != null)
     {
         GameObject.Destroy(effect.gameObject);
     }
 }
        public static void UnSpawnEffect(IManagedEffect eff)
        {
            var inst = Instance;

            if (inst != null && eff != null)
            {
                var pool = inst.mPools.GetData(eff.poolId);
                if (pool == null)
                {
                    Destroy(eff.gameObject);
                }
                else
                {
                    pool.Cache(eff);
                    if (eff.transform.parent != inst.transform)
                    {
                        eff.transform.SetParent(inst.transform);
                    }
                }
            }
            else if (eff != null)
            {
                Destroy(eff.gameObject);
            }
        }
        /// <summary>
        /// 生成特效对象
        /// </summary>
        /// <param name="poolId"></param>
        /// <param name="pos"></param>
        /// <param name="rot"></param>
        /// <param name="lifeTime">特效生存时间,如果大于等于0,将在这段时间之后自动加入到对象池,否则需要开发者通过 Unspawn 方法主动回收</param>
        /// <returns></returns>
        public static IManagedEffect SpawnEffect(int poolId, Vector3 pos, Quaternion rot, float lifeTime = -1)
        {
            var inst = Instance;

            if (inst == null || inst.mPools == null)
            {
                return(null);
            }
            var pool = inst.mPools.GetData(poolId);

            if (pool == null)
            {
                return(null);
            }
            pool.mTmpPos = pos;
            pool.mTmpRot = rot;
            IManagedEffect go = pool.Get();

            go.transform.position = pos;
            go.transform.rotation = rot;
            go.lifeTime           = lifeTime;
            go.Reactive();
            return(go);
        }
Пример #4
0
 public static void AddManagedEffect ( IManagedEffect effect )
 {
     managedEffects.Add( effect );
 }
Пример #5
0
 public static void AddManagedEffect(IManagedEffect effect)
 {
     managedEffects.Add(effect);
 }
 public void Remove(IManagedEffect eff)
 {
     mPool.Remove(eff);
 }
 public void Cache(IManagedEffect eff)
 {
     mPool.Add(eff);
 }