spawn from pool only if pool has inactive gameobjects

Hi, I’ve been searching for about a week now but can’t quite figure out an elegant solution to my problem.

I’d like to instantiate a gameobject from various pools only if there is a gameobject in the pools that is currently inactive.

For example, if there is a population number (300) and I have 250 active gameobjects from that population, how might I enable one but not spawn one if the population is 300. Again, I’m using different pools (young, middle-aged, old) and want to make sure that I don’t disable active game objects. I’m working with hundreds of gameobjects and want to be as performant as possible but I’m running into a mental block on this and appreciate any general guidance available. I think I’m misunderstanding something very basic because it seems that making a population int and comparing it every time is not as straight-forward as it could be.

Thank you.

When I do pooling I have a list for all the inactive objects. Usually a list for active objects is not needed, but if it is than that is easy enough to add. Anyways I use OnEnable() and OnDisable() to add and remove objects from lists. So then when I need to add an object from the pool I just grab the one at [0] and if the pool is empty then I instantiate a new object, if that is what is required.

Bump
Bump
Bump
Bump
Bump
Bump

I used this tutorial the first time I implemented and it worked great