Beispiel #1
0
        private void Awake()
        {
            if (!sActiveMgr)
            {
                sActiveMgr       = this;
                enabled          = true;
                mTickLifeEffects = new LinkedList <Effect>();
                mUseablePrefabs  = new GameObject[m_Prefabs.Count];
                m_Prefabs.CopyTo(mUseablePrefabs);

                mEffectPool = new ObjectPool <Effect>(mUseablePrefabs.Length, m_InitCapacity, InitEffect, DestroyEffect);
                for (int i = 0; i < mUseablePrefabs.Length; i++)
                {
                    if (mUseablePrefabs[i].activeInHierarchy)
                    {
                        mEffectPool.SaveBuffer(i, new Effect(i, mUseablePrefabs[i]));
                    }
                }
            }
            else
            {
                Debug.LogError("同一场景中只允许存在一个 SceneEffectManager 实例", this);
                enabled = false;
            }
        }
Beispiel #2
0
 private void OnDestroy()
 {
     if (sActiveMgr == this)
     {
         mTickLifeEffects.Clear();
         mEffectPool.Clear();
         sActiveMgr = null;
     }
 }