/// <summary> /// 释放 /// </summary> public virtual void Release() { m_isReleased = true; id = -1; unitTrans = null; foreach (var item in m_comDic.Values) { item.Release(); UnitComponentBase.RecoverComponent(item); } m_comDic.Clear(); }
/// <summary> /// 移除一个指定类型的组件 /// </summary> public void RemoveComponent <T>() where T : UnitComponentBase, new() { Type type = typeof(T); if (!m_comDic.ContainsKey(type)) { #if DEBUG Debug.LogError("移除角色组件错误,角色不含有该组件" + type.Name); #endif return; } UnitComponentBase com = m_comDic[type]; com.Release(); UnitComponentBase.RecoverComponent(com); m_comDic.Remove(type); }