public void CanReleaseObject() { IObjectPool <Dummy> objectPool = BuildObjectPool(); Dummy dummy = objectPool.Consume(); objectPool.Release(dummy); Assert.AreEqual(1, objectPool.GetAmountOfConsumeableObjects()); }
public override void Dispose() { base.Dispose(); m_TimeActionObjectPool.Release(); m_TimeActionObjectPool = null; m_TimeActionList.Clear(); m_TimeActionList = null; This = null; }
/// <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()); }
/// <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);
private void ReleaseItemView(TView itemView) { _viewPool.Release(itemView); itemView.gameObject.SetActive(false); }
public void ReturnComponent(T component) { pool.Release(component); }
public void Dispose() { Callback = null; pool.Release(this); }
public void ReturnInstance(GameObject instance) { pool.Release(instance); }