Пример #1
0
 /// <summary>
 /// 重置Component;
 /// </summary>
 public void Reset()
 {
     DeAttachEntity();
     DeAttachComponentObject();
     EventUnsubscribe();
     OnResetComponent();
     _id     = 0;
     _enable = false;
     _componentInitHandler = null;
 }
Пример #2
0
        /// <summary>
        /// 创建Component;
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="go"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public T CreateComponent <T>(BaseEntity entity, GameObject go, ComponentInitEventHandler handler) where T : BaseComponent, new()
        {
            T _Component = PoolMgr.Instance.Get <T>();

            if (AddComponent(_Component))
            {
                _Component.ComponentInitHandler = handler;
                _Component.Create(entity, go);
                return(_Component);
            }
            else
            {
                LogUtil.LogUtility.PrintError("[ComponentMgr]CreateComponent " + typeof(T).ToString() + " error!");
                return(null);
            }
        }