Пример #1
0
        /// <summary>
        /// Clears the released objects.
        /// 清理已经被释放的实例,并且对其进行回收
        /// </summary>
        public static void ClearReleasedObjects()
        {
            for (int i = m_listObject.Count - 1; i >= 0; i--)
            {
                if (m_listObject[i].IsReleased)
                {
                    EntityObject obj = m_listObject[i];
                    m_listObject.RemoveAt(i);

                    //将对象加入对象池
                    m_recycler.Push(obj);
                }
            }
        }
Пример #2
0
        public static void ReleaseView(EntityObject entity)
        {
            if (entity != null)
            {
                ViewObject obj = m_mapObject[entity];
                if (obj != null)
                {
                    if (EnableLog && Debuger.EnableLog)
                    {
                        Debuger.Log(LOG_TAG, "ReleaseView() {0}:{1} -> {2}:{3}",
                                    entity.GetType().Name, entity.GetHashCode(),
                                    obj.GetRecycleType(), obj.GetInstanceID());
                    }

                    m_mapObject.Remove(entity);
                    obj.ReleaseInFactory();
                    obj.gameObject.SetActive(false);

                    //将对象加入对象池
                    m_recycler.Push(obj);
                }
            }
        }