public void Clear()
        {
            while (spawned.Count > 0)
            {
                pool.Enqueue(spawned.Dequeue());
            }

            for (int i = 0; i < pool.Count; i++)
            {
                var instance = pool[i];
                DestroyImmediate(instance);
            }

            pool.Clear();
        }
        private void spawnInstance(GameObject instance, bool activate)
        {
            spawned.Enqueue(instance);

            // Find the PooledObject component and notify any observers of the despawn
            var poolComponent = instance.GetComponent <dfPooledObject>();

            if (poolComponent != null)
            {
                poolComponent.OnSpawned();
            }

            if (activate)
            {
                instance.SetActive(true);
            }
        }