From a5de63397ac50a27686e78a9fc61338d94e790ae Mon Sep 17 00:00:00 2001
From: ALEXTANG <574809918@qq.com>
Date: Mon, 18 Sep 2023 12:00:36 +0800
Subject: [PATCH] =?UTF-8?q?Update=203-4-=E5=AF=B9=E8=B1=A1=E6=B1=A0?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Books/3-4-对象池模块.md | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
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);
}