JUtils
A unity utilities library
JUtils.ObjectPool Class Reference

A simple implementation for an object pool More...

Inheritance diagram for JUtils.ObjectPool:
Collaboration diagram for JUtils.ObjectPool:

Public Member Functions

PoolItem SpawnItem ()
 Spawn a pooled item More...
 
PoolItem SpawnItem (Vector3 localPosition)
 Spawn a pooled item More...
 
PoolItem SpawnItem (Vector3 localPosition, Transform parent)
 Spawn a pooled item More...
 
PoolItem SpawnItem (Transform parent)
 Spawn a pooled item More...
 
PoolItem SpawnItem (Vector3 localPosition, Quaternion localRotation, Transform parent=null)
 Spawn a pooled item More...
 
bool TryGetItem (out PoolItem item)
 Get a pooled item, returns false if the pool can't auto expand and if there are no items left More...
 
int InstantiateNewItems (int amount=-1)
 Request X amount of items to be made More...
 
void SetTemplate (PoolItem newTemplate)
 Change the template of this object pool More...
 

Properties

PoolItem template [get]
 
IEnumerable< PoolItemactivePoolItems [get]
 
IEnumerable< PoolItemfreePoolItems [get]
 

Detailed Description

A simple implementation for an object pool

Disabling this component may result in erroneous behaviour

Member Function Documentation

◆ InstantiateNewItems()

int JUtils.ObjectPool.InstantiateNewItems ( int  amount = -1)
inline

Request X amount of items to be made

◆ SetTemplate()

void JUtils.ObjectPool.SetTemplate ( PoolItem  newTemplate)
inline

Change the template of this object pool

Template can only change when no object has been created

◆ SpawnItem() [1/5]

PoolItem JUtils.ObjectPool.SpawnItem ( )
inline

Spawn a pooled item

Here is the caller graph for this function:

◆ SpawnItem() [2/5]

PoolItem JUtils.ObjectPool.SpawnItem ( Transform  parent)
inline

Spawn a pooled item

References JUtils.ObjectPool.SpawnItem().

Here is the call graph for this function:

◆ SpawnItem() [3/5]

PoolItem JUtils.ObjectPool.SpawnItem ( Vector3  localPosition)
inline

Spawn a pooled item

References JUtils.ObjectPool.SpawnItem().

Here is the call graph for this function:

◆ SpawnItem() [4/5]

PoolItem JUtils.ObjectPool.SpawnItem ( Vector3  localPosition,
Quaternion  localRotation,
Transform  parent = null 
)
inline

Spawn a pooled item

◆ SpawnItem() [5/5]

PoolItem JUtils.ObjectPool.SpawnItem ( Vector3  localPosition,
Transform  parent 
)
inline

Spawn a pooled item

References JUtils.ObjectPool.SpawnItem().

Here is the call graph for this function:

◆ TryGetItem()

bool JUtils.ObjectPool.TryGetItem ( out PoolItem  item)
inline

Get a pooled item, returns false if the pool can't auto expand and if there are no items left

Property Documentation

◆ activePoolItems

IEnumerable<PoolItem> JUtils.ObjectPool.activePoolItems
get

◆ freePoolItems

IEnumerable<PoolItem> JUtils.ObjectPool.freePoolItems
get

◆ template

PoolItem JUtils.ObjectPool.template
get

The documentation for this class was generated from the following file: