Object pooling was one of my first systems that I pieced together fragments and tutorials of, converted into visual script, and started making my own changes. One of the first things I did was to make pathways; where objects were created one object per frame or one batch of objects per frame. This also included an interlock to check if the frame rate was below a threshold.

This worked ok. But awake, start and enable processes that maybe took a couple frames or triggered something else really weren’t accounted for too well such as when I started making a process to manage scene loading. Also, the perimeter cases of what happens if the pool stalls out for some reason, how do I want to manage adjustability. How to provide the objects without requiring checks. Getting feedback when some stage was ready. Then on top, enter Addressables.

Addressables are super cool. I think the ability to bundle assets together for the purpose of pushing updates or controlling memory by groups are great features. But I don’t want that management spread out to each area that is in use. For instance; you could call LoadAssetAsync locally which returns a handle with a result or only use the Addressables.Instantiate directly from the beginning. The handle is used to release the object when you are all done and needs to be stored. And the result can be used to create the objects. So, you can use Addressables.Instantiate and optionally have Unity “track handle” for each object created. Or use regular GameObject.Instantiate and track the count yourself at which point you could release the original handle at zero. You can use a coroutine or async-await. You can provide the AssetReference directly to Addressables or a string guid or a resource location or a label for a group and I’m sure there are a few more options. There is a steep learning curve.

I wanted pool usage to be standardized, seamless and centralized even if limited in absolute functionality. Any maintenance of an object would be through the pool and the caller only worries about requesting an object. No creating each individual pool by object. Minimal changes to update code. Still works with non-addressables calls like using a prefab reference with your request to the pool as you would normally. I also didn’t want to be directly managing memory tracking, like counting and caching handles, because I think that’s outside the scope and so I preferred to utilize the Unity tracking features.

Unity has recently come out with the UnityEngine.Pool API. I think it’s a great addition but I don’t think it is providing the same features. You will use Addressables from outside the pool before making requests, managing counts yourself in multiple areas, creating each pool per object, and I haven’t seen anything about respecting the gameplay environment aka frame-rate. Maybe I’m totally off, I’m no expert on it, but I care about behavior if not every exacting detail. This suits my purposes and I think maybe it could help someone else and grow.