// Object was destroyed, remove it from it's active pool and put it in the inactive pool
    //  for later use.
    public static void ObjectDestroyed(GameObject obj)
    {
        if ((activePools == null) || (inactivePools == null))
        {
            Debug.LogError("Pool dictionaries not created!");
            return;
        }

        ManagedPoolObject mpo = obj.GetComponent <ManagedPoolObject>( );

        if (mpo == null)
        {
            Debug.LogError("Attempting to move unmanaged object to an inactive pool! Destroying object! " + obj);
            Destroy(obj);
            return;
        }

        if (!CheckPools(mpo.managedPrefab))
        {
            Debug.LogError("Attempting to move an object to an inactive pool that doesn't exist! Destorying object! " + obj);
            Destroy(obj);
            return;
        }

        LinkedList <GameObject>     activePool   = activePools[mpo.managedPrefab];
        LinkedList <GameObject>     inactivePool = inactivePools[mpo.managedPrefab];
        LinkedListNode <GameObject> objectNode;

        objectNode = activePool.Find(obj);
        if (objectNode == null)
        {
            Debug.LogError("Attempting to move an object that isn't in an active pool to an inactive pool! " + obj);
            return;
        }

        // do the deactivation of the object
        obj.transform.parent = null;
        obj.BroadcastMessage("PoolDestroy", SendMessageOptions.DontRequireReceiver);
        obj.SetActive(false);

        activePool.Remove(objectNode);
        inactivePool.AddFirst(objectNode);

        if (leakCheck)
        {
            LeakCheck( );
        }
    }
    // Create a LinkedListNode containing an instance of prefab as the value.
    static LinkedListNode <GameObject> CreatePoolObject(GameObject prefab)
    {
        //Debug.Log ("***** Creating pool object: "+prefab);
        GameObject newObj = (GameObject)Instantiate((UnityEngine.Object)prefab);
        LinkedListNode <GameObject> objectNode = new LinkedListNode <GameObject>(newObj);

        newObj.name += idNum;
        ++idNum;

        // make sure the new object doesn't have the managed component
        if (newObj.GetComponent <ManagedPoolObject>( ) != null)
        {
            Debug.LogWarning("Creating object from prefab that already has the ManagedPoolObject component. Please remove it. " + prefab);
            Destroy(newObj.GetComponent <ManagedPoolObject>( ));
        }
        ManagedPoolObject mpo = newObj.AddComponent <ManagedPoolObject>( );

        mpo.managedPrefab = prefab;

        return(objectNode);
    }