Beispiel #1
0
    /// <summary>
    /// Callback used for when a used poolable object needs to be inactivated and go back into the pool
    /// </summary>
    /// <param name="obj"></param>
    protected virtual void OnReturnToPoolCallback(IPoolable obj)
    {
        if (inactiveObjects.Contains(obj))
        {
            return;
        }

        usedObjects.Remove(obj);
        if (CurrentPoolSize > InitialPoolSize)
        {
            DestroyObject(obj);
            return;
        }

        obj.BecomeInactive();
        inactiveObjects.Add(obj);
    }