Пример #1
0
 /// <summary>
 /// 销毁组件;
 /// </summary>
 /// <param name="component"></param>
 /// <returns></returns>
 public bool DestroyComponent(AbsComponent component)
 {
     for (var i = 0; i < _componentList.Count; i++)
     {
         var target = _componentList[i];
         if (target == component)
         {
             component.UnInitialize();
             _componentList.Remove(component);
             _releaseComponentUIDList.Add(target.UID);
             return(true);
         }
     }
     LogHelper.PrintError($"[ComponentMgr]DestroyComponent {component.GetType().ToString()} error,can not find the component!");
     return(false);
 }
Пример #2
0
 /// <summary>
 /// 移除组件;
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="component"></param>
 /// <returns></returns>
 public bool ReleaseComponent <T>(AbsComponent component) where T : AbsComponent, new()
 {
     if (component as T == null)
     {
         LogHelper.PrintError($"[ComponentMgr]ReleaseComponent error:comp as {typeof(T).ToString()} is null.");
         return(false);
     }
     for (var i = 0; i < _componentList.Count; i++)
     {
         var target = _componentList[i];
         if (target == component)
         {
             component.UnInitialize();
             PoolMgr.singleton.ReleaseCsharpObject(component as T);
             _componentList.Remove(target);
             _releaseComponentUIDList.Add(target.UID);
             return(true);
         }
     }
     LogHelper.PrintError($"[ComponentMgr]ReleaseComponent {typeof(T).ToString()} error,can not find the component.");
     return(false);
 }