/// <summary> /// 释放 /// </summary> /// <param name="force"></param> /// <returns></returns> public bool Release(bool force = false) { bool sucess = false; if (CanRelease(force)) { //if (m_sPoolName.Contains("MainPanel")) //{ // Debug.LogError("Destory Main Release"); //} this.m_prefabObj = null; this.m_parent = null; GameObject.Destroy(this.m_objMount.gameObject); this.m_objMount = null; for (int i = 0, max = m_lstInactive.Count; i < max; i++) { if (null == m_lstInactive[i]) { continue; } GameObject.Destroy(m_lstInactive[i].gameObject); } this.m_lstInactive.Clear(); for (int i = 0, max = m_lstActive.Count; i < max; i++) { if (null == m_lstActive[i]) { continue; } GameObject.Destroy(m_lstActive[i].gameObject); } this.m_lstActive.Clear(); if (null != cloneTs) { GameObject.Destroy(cloneTs.gameObject); } m_state = CMObjPoolState.Release; PrintMessage("ObjPoot {0} Change to sate {1}", m_sPoolName, m_state); } return(sucess); }
/// <summary> /// 切换状态 /// </summary> /// <param name="state"></param> private void ChangeState(CMObjPoolState state) { if (m_state == CMObjPoolState.Release) { return; } if (m_state != state) { bool setSuccess = true; switch (state) { case CMObjPoolState.Active: { m_fLasetActiveTimeStamp = PoolTimeStamp; } break; case CMObjPoolState.Idle: { m_fIdleStatusStartTimeStamp = PoolTimeStamp; HandleIdle(); PrintMessage("ObjPoot {0} Change to sate {1}", m_sPoolName, m_state); } break; case CMObjPoolState.Release: { setSuccess = Release(); } break; } if (setSuccess) { m_state = state; } } }