Esempio n. 1
0
    public void DisposeTransform(Transform transform, bool forceDestroy)
    {
        IzPoolObject izPoolObject = transform.GetComponent <PoolObject>();       //TODO Denes 这里可以尝试优化
        IzSpawnPool  izSpawnPool  = null;

        if (izPoolObject != null && this._dicSpawnPool.TryGetValue(izPoolObject.GetPoolName(), out izSpawnPool) && izSpawnPool != null)
        {
            izSpawnPool.DisposeTransform(transform, forceDestroy);
        }
        else
        {
            UnityEngine.Object.Destroy(transform.gameObject);//不在池里的对象,直接destroy
        }
    }
Esempio n. 2
0
    public Transform GetTransform <T>(string strPathName)
    {
        string      strPoolName = typeof(T).Name;
        IzSpawnPool izSpawnPool = null;

        if (!this._dicSpawnPool.TryGetValue(strPoolName, out izSpawnPool))
        {
            izSpawnPool = SpawnPool.CreateSpawnPool(strPoolName, this, this._rootGameObject);
            this._dicSpawnPool[strPoolName] = izSpawnPool;
        }
        Transform transform = izSpawnPool.GetTransform(strPathName);

        if (null == transform)
        {
            return(null);
        }

        if (transform.gameObject.activeSelf == false)
        {
            transform.gameObject.SetActive(true);
        }
        return(transform);
    }