diff --git a/Books/3-4-对象池模块.md b/Books/3-4-对象池模块.md index 62159d9a..debdbd2b 100644 --- a/Books/3-4-对象池模块.md +++ b/Books/3-4-对象池模块.md @@ -13,6 +13,19 @@ public class Actor : ObjectBase /// /// 是否是关闭对象池时触发。 protected override void Release(bool isShutdown){} + + /// + /// 创建Actor对象。 + /// + /// 对象名称。 + /// 对象持有实例。 + /// + public static Actor Create(string name, object target) + { + var actor = MemoryPool.Acquire(); + actor.Initialize(name, target); + return actor; + } } /// @@ -29,8 +42,10 @@ void Start() /// /// 创建Actor对象。 /// -/// Actor对象实例。 -public Actor CreateActor() +/// 对象名称。 +/// 对象持有实例。 +/// Actor对象实例 +public Actor CreateActor(string actorName, GameObject target) { Actor ret = null; if (_actorPool.CanSpawn()) @@ -39,7 +54,7 @@ public Actor CreateActor() } else { - ret = MemoryPool.Acquire(); + ret = Actor.Create(actorName, target); _actorPool.Register(ret,true); }