GameObject Pooler
FreakLib.Pooling.Pool Class Reference

The main Pool class, which contains the main interface for interacting with the Pool. More...

Inheritance diagram for FreakLib.Pooling.Pool:

Static Public Member Functions

static void InstantiatePool (bool asyncInstantiate=false)
 Instantiates the pool. More...
 
static void ClearPool ()
 Clears the pool. More...
 
static PoolItem AddPoolItem (GameObject original, int initialCapacity=1)
 Adds an item to the Pool. More...
 
static PoolItem AddPoolItem (PoolItem item)
 Adds an item to the Pool. More...
 
static void RemovePoolItem (GameObject original)
 Removes the object from the Pool. More...
 
static void RemovePoolItem (PoolItem item)
 Removes the PoolItem from the Pool. More...
 
static void GetPoolItem (GameObject original, out PoolItem p)
 Gets the associated PoolItem for a given original. More...
 
static bool ExistsInPool (GameObject original)
 Checks if a GameObject exists in the Pool. More...
 
static PoolItem[] GetPoolItems ()
 Gets all the pool items. More...
 
static GameObject Borrow (GameObject original)
 Borrow a copy of the specified original object from the Pool. More...
 
static GameObject Borrow (GameObject original, Vector3 position)
 Borrow a copy of the specified original object from the Pool, and position it at the specified position. More...
 
static GameObject Borrow (GameObject original, Vector3 position, Quaternion rotation)
 Borrow a copy of the specified original object from the Pool, and position it at the specified position with the specified rotation. More...
 
static void Return (GameObject obj)
 Return the specified object to the Pool. More...
 
static void Return (GameObject obj, float t)
 Return the specified object to the Pool after a delay. More...
 

Properties

static Pool Instance [get]
 Gets the singleton instance. More...
 
static bool IsInstantiated [get]
 Gets a value indicating if the pool is instantiated. More...
 
static bool IsQuitting [get]
 Gets a value indicating if the application is quitting. More...
 
static bool WarnOnGrow [get, set]
 Gets or sets a value indicating whether this FreakLib.Pooling.Pool should warn on grow. More...
 
static bool UseInterfaceCallbacks [get, set]
 Gets or sets a value indicating whether this FreakLib.Pooling.Pool should use interface callbacks. More...
 

Detailed Description

The main Pool class, which contains the main interface for interacting with the Pool.

This is a singleton class, and so there should only ever be one Pool in any given scene in Unity.

Member Function Documentation

static PoolItem FreakLib.Pooling.Pool.AddPoolItem ( GameObject  original,
int  initialCapacity = 1 
)
static

Adds an item to the Pool.

If the original item to be added already exists in the pool, this will print an error in the console and return the PoolItem already associated with the original.

Returns
The PoolItem for the original.
Parameters
originalOriginal GameObject.
initialCapacityInitial capacity.
static PoolItem FreakLib.Pooling.Pool.AddPoolItem ( PoolItem  item)
static

Adds an item to the Pool.

If the original item to be added already exists in the pool, this will print an error in the console and return the PoolItem already associated with the original.

Returns
The PoolItem.
Parameters
itemPoolItem to add.
static GameObject FreakLib.Pooling.Pool.Borrow ( GameObject  original)
static

Borrow a copy of the specified original object from the Pool.

Parameters
originalOriginal object.
static GameObject FreakLib.Pooling.Pool.Borrow ( GameObject  original,
Vector3  position 
)
static

Borrow a copy of the specified original object from the Pool, and position it at the specified position.

Parameters
originalOriginal object.
positionPosition.
static GameObject FreakLib.Pooling.Pool.Borrow ( GameObject  original,
Vector3  position,
Quaternion  rotation 
)
static

Borrow a copy of the specified original object from the Pool, and position it at the specified position with the specified rotation.

Parameters
originalOriginal object.
positionPosition.
rotationRotation.
static void FreakLib.Pooling.Pool.ClearPool ( )
static

Clears the pool.

This will remove all items from the pool.

static bool FreakLib.Pooling.Pool.ExistsInPool ( GameObject  original)
static

Checks if a GameObject exists in the Pool.

Returns
true, if original exists in Pool, false otherwise.
Parameters
originalOriginal object.
static void FreakLib.Pooling.Pool.GetPoolItem ( GameObject  original,
out PoolItem  p 
)
static

Gets the associated PoolItem for a given original.

Parameters
originalOriginal object.
pThe PoolItem for the original, will be null if the original doesn't exist in the Pool.
static PoolItem [] FreakLib.Pooling.Pool.GetPoolItems ( )
static

Gets all the pool items.

Returns
An array of PoolItem.
static void FreakLib.Pooling.Pool.InstantiatePool ( bool  asyncInstantiate = false)
static

Instantiates the pool.

To check if the pool has been instantiated, check the Pool.IsInstantiated property.

Instantiating the pool can take a long time, it is therefore possible to instantiate it asynchronously, by passing true to this function. It will then only instantiate one pool object per frame. This takes a little longer, but will keep you application from appearing to have frozen.

Parameters
asyncInstantiateIf set to true async instantiate.
static void FreakLib.Pooling.Pool.RemovePoolItem ( GameObject  original)
static

Removes the object from the Pool.

Parameters
originalObject to remove.
static void FreakLib.Pooling.Pool.RemovePoolItem ( PoolItem  item)
static

Removes the PoolItem from the Pool.

Parameters
itemPoolItem to remove.
static void FreakLib.Pooling.Pool.Return ( GameObject  obj)
static

Return the specified object to the Pool.

Parameters
objOriginal object.
static void FreakLib.Pooling.Pool.Return ( GameObject  obj,
float  t 
)
static

Return the specified object to the Pool after a delay.

Parameters
objOriginal object.
tTime before returning object.

Property Documentation

Pool FreakLib.Pooling.Pool.Instance
staticget

Gets the singleton instance.

The instance.

bool FreakLib.Pooling.Pool.IsInstantiated
staticget

Gets a value indicating if the pool is instantiated.

true if is instantiated; otherwise, false.

bool FreakLib.Pooling.Pool.IsQuitting
staticget

Gets a value indicating if the application is quitting.

true if is quitting; otherwise, false.

bool FreakLib.Pooling.Pool.UseInterfaceCallbacks
staticgetset

Gets or sets a value indicating whether this FreakLib.Pooling.Pool should use interface callbacks.

true if interface callbacks should be used; otherwise, false.

bool FreakLib.Pooling.Pool.WarnOnGrow
staticgetset

Gets or sets a value indicating whether this FreakLib.Pooling.Pool should warn on grow.

true if warn on grow; otherwise, false.


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