UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Utility Systems / Pooling System Completed

Utility Systems — UGTK

Pooling System

Summary

The Pooling System within the Unity Games Toolkit (UGTK) is designed to efficiently manage and reuse GameObject instances. This system is commonly used to optimize resource-intensive operations such as frequent instantiation and destruction of objects. It includes functionality for initializing pools, activating and deactivating objects, and dynamically expanding the pool when needed.


Content


Modules Dependencies

The Pooling System module does not have external dependencies within the UGTK. It can be used independently.


Setup

To set up the Pooling System, follow these steps:

  1. Add Poolerprefab in your scene:

  2. Configure the Mn_Pooler setting the Poolable Object, the Pool Stack, or changing ActiveParent or DeactiveParent:


How To Use

To use the Pooling System, use the following functions, called by code in an other script (Substitute myPooler with your pooler variable and T with the type of the component attached to your prefabObjectToPool):

  1. Get First Avaiable Object:
    GameObject obj = myPooler.GetFirstAvaiableObject();
  1. Active an Object(attachToActiveParent is setted to true by default, therefore, you can omit specifying it in the function):
    GameObject obj;
    bool attachToActiveParent;
    myPooler.ActivateObject(obj, attachToActiveParent);
  1. Get First Avaiable T component:
    T comp = myPoolerGetFirstAvaiableComponent<T>();
  1. Active a component of T type(attachToActiveParent is setted to true by default, therefore, you can omit specifying it in the function):
    T comp;
    bool attachToActiveParent;
    myPooler.ActivateComponent(comp, attachToActiveParent)
  1. Has Element:
    GameObject obj;
    bool hasElement = myPooler.HasElement(obj);
  1. Has Component:
    T comp;
    bool hasElement = myPooler.HasComponent(comp);

Testing Scene

Open PoolableScene in the module's Debug/ folder and select Pooler User > 3DPooler. The Editor Test Tools block needs Play mode - the pool is filled at runtime, and outside Play the block says so rather than showing an empty one.

What to do, in order:

  1. Press GetFirstAvailableObject() — take one out a few times and watch Active objects climb.
  2. Set Amount to 5 and press Take N out, then Return every active object to the pool: the counter goes back to zero in one click.
  3. Take more than the pool holds (Pool Stack is 15 here).
  4. Return the same object twice from your own code.
  5. Set the active parent to an object that is inactive in the hierarchy.

Step 3 is the decision every pool has to make — grow, or refuse — and the answer changes how the game behaves under load. Step 5 is the classic false report: the object is taken, the counter says it is active, and nothing appears on screen because its parent is switched off.


Technical Info

The Pooling System module is composed of several key scripts and structures to manage and optimize GameObject instantiation and destruction.

Functs:


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 2 modules in total.