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 } }
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); }