/// <summary>
    ///
    /// </summary>
    /// <param name="eType"></param>
    /// <returns></returns>
    public GameObject Spwan(string sKey)
    {
        CObjectPoolWrapper <GameObject> obj = null;

        CObjectPool <GameObject> objectPool = null;

        int key = CRC32.GetHashForAnsi(sKey);

        if (poolList.TryGetValue(key, out objectPool))
        {
            obj = objectPool.Take();

            PoolObject info = obj.Value.GetComponent <PoolObject>();

            if (info == null)
            {
                info = obj.Value.AddComponent <PoolObject>();
            }

            info.obj     = obj;
            info.hashKey = key;

            obj.Value.transform.parent = null;
            obj.Value.SetActive(true);

            return(obj.Value);
        }

        return(null);
    }
示例#2
0
    /// <summary>
    /// Put the object back into the pool.
    /// </summary>
    /// <param name="obj"></param>
    public void Release(CObjectPoolWrapper <T> obj)
    {
        if (OnRelease != null)
        {
            OnRelease(obj.Value);
        }

        objects.Push(obj);
    }