public Transform GetPools(PoolEnums.PoolId poolID, bool IsEnable = true) { var poolKey = PoolEnums.GetPoolKey(poolID); Transform poolReturn = null; List <Transform> poolExport = null; if (poolSaver.TryGetValue(poolKey, out poolExport)) { if (poolExport.Count > 0) { poolReturn = poolExport[0]; poolExport.RemoveAt(0); } } if (ReferenceEquals(poolReturn, null)) { poolReturn = InstancePool(poolID); } if (!ReferenceEquals(poolReturn, null) && poolReturn.gameObject.activeSelf != IsEnable) { poolReturn.gameObject.SetActive(IsEnable); } return(poolReturn); }
public PoolManager SetPools(PoolEnums.PoolId poolID, Transform poolComponent) { var poolKey = PoolEnums.GetPoolKey(poolID); List <Transform> poolImport = null; if (poolSaver.TryGetValue(poolKey, out poolImport)) { if (!poolImport.Contains(poolComponent)) { poolImport.Add(poolComponent); } } else { poolImport = new List <Transform> { poolComponent }; poolSaver.Add(poolKey, poolImport); } if (poolComponent.gameObject.activeSelf == true) { poolComponent.gameObject.SetActive(false); } return(this); }
public PoolManager RemovePoolKeys(PoolEnums.PoolId poolID, bool IsDestroy = true) { var poolKey = PoolEnums.GetPoolKey(poolID); if (IsDestroy) { List <Transform> poolExport = null; if (poolSaver.TryGetValue(poolKey, out poolExport)) { for (int i = 0; i < poolExport.Count; i++) { Destroy(poolExport[i].gameObject); } } } if (poolSaver.ContainsKey(poolKey)) { poolSaver.Remove(poolKey); } return(this); }