/// <summary> /// 移除Component; /// </summary> /// <param name="comp"></param> public void DestroyComponent(AbsComponent comp) { if (null == comp.Owner || null == comp) { return; } comp.Owner.DestroyComponent(comp); }
/// <summary> /// 移除Component; /// </summary> /// <typeparam name="T"></typeparam> /// <param name="comp"></param> public void ReleaseComponent <T>(AbsComponent comp) where T : AbsComponent, new() { if (null == comp || null == comp.Owner) { return; } if (comp.Owner.ReleaseComponent <T>(comp)) { comp = null; } }
/// <summary> /// 销毁组件; /// </summary> /// <param name="comp"></param> /// <returns></returns> public bool DestroyComponent(AbsComponent comp) { for (int i = 0; i < _componentList.Count; i++) { var targetComp = _componentList[i]; if (targetComp == comp) { comp.UnInitialize(); _componentList.Remove(comp); return(true); } } LogHelper.PrintError("[ComponentMgr]DestroyComponent " + comp.GetType().ToString() + " error,can not find the component!"); return(false); }
/// <summary> /// 移除组件; /// </summary> /// <typeparam name="T"></typeparam> /// <param name="comp"></param> /// <returns></returns> public bool ReleaseComponent <T>(AbsComponent comp) where T : AbsComponent, new() { if (comp as T == null) { LogHelper.PrintError("[ComponentMgr]ReleaseComponent error:comp as" + typeof(T).ToString() + " is null!"); return(false); } for (int i = 0; i < _componentList.Count; i++) { var targetComp = _componentList[i]; if (targetComp == comp) { comp.UnInitialize(); PoolMgr.Instance.ReleaseCsharpObject <T>(comp as T); _componentList.Remove(targetComp); return(true); } } LogHelper.PrintError("[ComponentMgr]ReleaseComponent " + typeof(T).ToString() + " error,can not find the component!"); return(false); }