/// <summary>
/// Populates the GameObject's object pool to the specified amount within an enumerator. Intended to work with
/// https://github.com/GalvanicGames/unity-game-loader
/// </summary>
/// <param name="obj"></param>
/// <param name="amount"></param>
/// <returns></returns>
public static IEnumerator PopulatePoolCo(this GameObject obj, int amount)
{
PoolableGameObject poolable = obj.GetComponent <PoolableGameObject>();
if (poolable == null)
{
Debug.LogErrorFormat(REQUIRES_COMP, obj.name, "PopulatePool");
}
else
{
int amountToAdd = amount - poolable.AmountInPool();
for (int i = 0; i < amountToAdd; i++)
{
poolable.IncrementPool();
yield return(null);
}
}
yield return(null);
}