public static T CreateWithParent <T, A, B, C>(Entity parent, A a, B b, C c) where T : Entity, new() { T t = ObjectPool.Instance.Fetch <T>(); parent.AddChild(t); EventSystem.Instance.Awake(t, a, b, c); EventSystem.Instance.RegisterSystem(t); return(t); }
/// <summary> /// 添加组件 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="name">游戏物体名称</param> public static T AddUIComponentNotCreate <T>(this Entity self, string name) where T : Entity, IAwake, IOnEnable { Type type = typeof(T); T component_inst = self.AddChild <T>(); UIManagerComponent.Instance.pathMap[component_inst.Id] = name; self.RecordUIComponent(name, type, component_inst); self.SetLength(self.GetLength() + 1); return(component_inst); }
/// <summary> /// 添加组件 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="path">路径</param> public static T AddUIComponent <T>(this Entity self, string path = "") where T : Entity, IAwake, IOnCreate, IOnEnable { Type type = typeof(T); T component_inst = self.AddChild <T>(); UIManagerComponent.Instance.pathMap[component_inst.Id] = path; self.RecordUIComponent(path, type, component_inst); Game.EventSystem.Publish(new UIEventType.AddComponent() { Path = path, entity = component_inst }); UIEventSystem.Instance.OnCreate(component_inst); self.SetLength(self.GetLength() + 1); return(component_inst); }