PooledObjectCreator¶
Item creator that pools GameObjects for reuse.
Namespace: Jungle.Objects
Inherits: GameObjectCreator → ControllableComponent → MonoBehaviour
Implements: IItemCreator<GameObject>, IPoolObjectOwner
Overview¶
PooledObjectCreator pre-instantiates a prefab on Awake (up to initialCount), grows up to maxCount on demand, and reclaims released instances back into an inactive reserve for future Create calls. Each pooled instance carries a PoolObject component — one is added automatically if the prefab doesn't have one.
For agent-facing take/store semantics on top of a creator, compose with CreatorBackedContainer<T> (typically GameObjectCreatorBackedContainer).
For one-off "instantiate + destroy" without reuse, use InstanceObjectCreator.
Properties¶
| Property | Type | Description |
|---|---|---|
| prefab | IGameObjectValue |
Prefab to instantiate. Auto-gets a PoolObject at runtime if missing. |
| initialCount | int |
Number of objects to pre-instantiate on Awake. |
| maxCount | int |
Maximum total pool size. 0 for unlimited. |
| poolParent | Transform |
Parent transform for pooled (inactive) objects. Uses this transform if not set. |
| maxActive | int |
Maximum active (acquired) objects. When exceeded, the oldest is force-returned. 0 for unlimited. |
Runtime State¶
| Member | Description |
|---|---|
InactiveCount |
Number of objects ready to be acquired (pool reserve). |
ActiveCount |
Number of objects currently in use. |
TotalCount |
Total objects managed by this pool (active + inactive). |
Inactive |
Read-only IItemSource<GameObject> view of the pool reserve. |
Methods¶
| Method | Description |
|---|---|
Create(Action<GameObject>) |
Acquires the next available pooled instance (or grows the pool). |
Reclaim(GameObject, Action) |
Returns an instance to the inactive reserve. |
DestroyItem(GameObject) |
Permanently removes a pooled instance. |
ReleaseAll() |
Force-reclaims every active object back into the pool. |