PoolManager

Added in FPS Engine 1.3.6

A Pool System is used to manage object reuse efficiently, reducing instantiation and destruction overhead. Instead of creating and destroying objects repeatedly (which can hurt performance), a pool system pre-instantiates a set of objects and enables/disables them as needed.

This system improves performance, prevents frame-rate drops, and is easily customizable in FPS Engine.

The Pool Manager can be found as a child of GeneralManagers object within the Player

Functions & Accesors | PoolManager.cs

Instance ( PoolManager ) / Public Static Singleton

PoolManager Singleton

WeaponEffectsSize ( int ) / Public Getter, Private Setter

Returns the size of the pre-instantiated collection of Weapon Effects.

DamagePopUpsSize ( int ) / Public Getter, Private Setter

Returns the size of the pre-instantiated collection of Damage Pop Up Effects.

BulletGraphicsSize ( int ) / Public Getter, Private Setter

Returns the size of the pre-instantiated collection of Bullet Graphics Effects.

Default Return Time ( float ) / Public Getter, Private Setter

If not specified, time to wait for an object to be returned to the pool.

Damage Pop Ups Time ( float ) / Public Getter, Private Setter

Time to wait for a Damage Pop Up specifically to be returned to the pool.

RegisterPool ( GameObject prefab, int size )

Registers a new pool given a prefab and the size of the collection.

  • prefab: Prefab that defines the new collection of the Pool. "size" instances of this prefab will be pre-instantiated as soon as the new collection is registered.

  • size: Amount of instance of "prefab" to pre-instantiate when the collection is registered.

GetFromPool ( GameObject prefab, Vector3 position, Quaternion rotation )

Gets a specific prefab from an existing collection and places it at the desired position and rotation. Applies default return times as it is not specified.

  • prefab: Prefab that defines the collection of the Pool.

  • position: Position to locate the prefab on get from the pool.

  • rotation: Rotation to locate the prefab on get from the pool.

GetFromPool ( GameObject prefab, Vector3 position, Quaternion rotation, float returnToPool )

Gets a specific prefab from an existing collection and places it at the desired position and rotation. Specifies return times.

  • prefab: Prefab that defines the collection of the Pool.

  • position: Position to locate the prefab on get from the pool.

  • rotation: Rotation to locate the prefab on get from the pool.

  • returnToPool: Time to return to pool.

ReturnToPool ( GameObject obj, GameObject prefab )

Returns an object to the pool if obj exists in the prefab collection.

  • obj: Object to return to pool.

  • prefab: Prefab that defines the collection of the pool.

Last updated