Skip to content

Pooling

Andrés Eduardo Maldonado edited this page Jul 26, 2019 · 6 revisions

Public static class.

Description

This is the entry point to the system. Use this to spawn GameObjects that will be used frequently.

Usage

Use Pooling.GetFromPool(GameObject, Vector3, Quaternion) instead of Instantiate().

Use Pooling.SendToPool(GameObject) instead of Destroy().

Static Methods

Returns Name Description
GameObject[] Preload Spawns the prefabs then deactivates them ready to be used. This will call Awake but not IPoolable.OnPoolSpawn nor IPoolable.OnPoolUnSpawn.
GameObject GetFromPool (2 Overloads) Gets one inactive object from a pool then activates it. If the object doesn't exist, a new pool will be created. This will call IPoolable.OnPoolSpawn.
void SendToPool Collects the object to its pool then deactivates it, ready for next use. If it doesn't have a pool, it will be destroyed. This will call IPoolable.OnPoolUnSpawn.

Public Enum

See Pooling.Category

Private Static

Additionally you can configure the log messages to show:

// :: Console Log Settings
public static readonly bool LOG_MESSAGE = true;
public static readonly bool LOG_WARNINGS = true;
public static readonly bool LOG_ERRORS = true;