public void CanReleaseObject()
        {
            IObjectPool <Dummy> objectPool = BuildObjectPool();
            Dummy dummy = objectPool.Consume();

            objectPool.Release(dummy);

            Assert.AreEqual(1, objectPool.GetAmountOfConsumeableObjects());
        }
Exemplo n.º 2
0
        public override void Dispose()
        {
            base.Dispose();

            m_TimeActionObjectPool.Release();
            m_TimeActionObjectPool = null;
            m_TimeActionList.Clear();
            m_TimeActionList = null;

            This = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 释放对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pooledObject"></param>
        public void ReleaseObject(IPooledObject pooledObject)
        {
            Type        type       = pooledObject.GetType();
            IObjectPool objectPool = GetObjectPool(type);

            if (objectPool == null)
            {
                objectPool = RegisterObjectPool(type);
            }

            objectPool.Release(pooledObject);
        }
        public void ReturnsTheSameObjectAfterItsBeenReleased()
        {
            IObjectPool <Dummy> objectPool = BuildObjectPool();

            Dummy dummy = objectPool.Consume();

            objectPool.Release(dummy);

            Dummy dummy2 = objectPool.Consume();

            Assert.AreSame(dummy, dummy2);
            Assert.AreEqual(0, objectPool.GetAmountOfConsumeableObjects());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData, bool isRelease = false)
        {
            Guard.Verify <ArgumentException>(uiForm == null, $"UI form is invalid.");

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            Guard.Verify <ArgumentException>(uiGroup == null, $"UI group is invalid.");

            // 先关闭前台界面,再激活后台界面
            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            if (isRelease)
            {
                m_InstancePool.Release(uiForm.UIFormInstance);
            }
            else
            {
                m_InstancePool.Unspawn(uiForm.UIFormInstance);
            }
        }
 public void ReturnPooledObject(GameObject gameObject)
 {
     objectPool.Release(gameObject);
 }
 void IDisposable.Dispose() => m_Pool.Release(m_ToReturn);
Exemplo n.º 8
0
 private void ReleaseItemView(TView itemView)
 {
     _viewPool.Release(itemView);
     itemView.gameObject.SetActive(false);
 }
Exemplo n.º 9
0
 public void ReturnComponent(T component)
 {
     pool.Release(component);
 }
Exemplo n.º 10
0
 public void Dispose()
 {
     Callback = null;
     pool.Release(this);
 }
Exemplo n.º 11
0
 public void ReturnInstance(GameObject instance)
 {
     pool.Release(instance);
 }