mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update 3-4-对象池模块.md
This commit is contained in:
@@ -13,6 +13,19 @@ public class Actor : ObjectBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isShutdown">是否是关闭对象池时触发。</param>
|
/// <param name="isShutdown">是否是关闭对象池时触发。</param>
|
||||||
protected override void Release(bool isShutdown){}
|
protected override void Release(bool isShutdown){}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建Actor对象。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="actorName">对象名称。</param>
|
||||||
|
/// <param name="target">对象持有实例。</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Actor Create(string name, object target)
|
||||||
|
{
|
||||||
|
var actor = MemoryPool.Acquire<Actor>();
|
||||||
|
actor.Initialize(name, target);
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -29,8 +42,10 @@ void Start()
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建Actor对象。
|
/// 创建Actor对象。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Actor对象实例。</returns>
|
/// <param name="actorName">对象名称。</param>
|
||||||
public Actor CreateActor()
|
/// <param name="target">对象持有实例。</param>
|
||||||
|
/// <returns>Actor对象实例</returns>
|
||||||
|
public Actor CreateActor(string actorName, GameObject target)
|
||||||
{
|
{
|
||||||
Actor ret = null;
|
Actor ret = null;
|
||||||
if (_actorPool.CanSpawn())
|
if (_actorPool.CanSpawn())
|
||||||
@@ -39,7 +54,7 @@ public Actor CreateActor()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = MemoryPool.Acquire<Actor>();
|
ret = Actor.Create(actorName, target);
|
||||||
_actorPool.Register(ret,true);
|
_actorPool.Register(ret,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user