/// <summary> /// The object is called up and removed from the pool for use. /// </summary> /// <param name="POOLNAMES">The enum tag of the Pool of which it is a member</param> /// <param name="_position"> </param> /// <returns></returns> public GameObject PullFromPool(PoolNames POOLNAMES, Vector3 _position, bool active = true) { for (int i = 0; i < poolings.Length; i++) { if (poolings[i].POOLNAMES == POOLNAMES) { return(poolings[(int)POOLNAMES].PullFromPool(_position, active)); } } return(null); }
/// <summary> /// The object goes back to the pool where it was extracted. /// </summary> /// <param name="POOLNAMES">The enum tag of the Pool of which it is a member</param> /// <param name="gameObject">Object that needs to go to the pool</param> public void BackToPool(PoolNames POOLNAMES, GameObject gameObject) { for (int i = 0; i < poolings.Length; i++) { if (poolings[i].POOLNAMES == POOLNAMES) { poolings[i].AddPool(gameObject); break; } } }
void RandomDestroy(PoolNames poolNames) { //this method is bad but I used it to get you to grasp the pooling pattern method. PoolMember[] member = FindObjectsOfType <PoolMember>(); if (member == null) { return; } foreach (PoolMember item in member) { if (item.poolNames == poolNames) { item.gameObject.SetActive(false); return; } } }
void Create(PoolNames poolNames) { PoolManager.Instance.PullFromPool(poolNames, new Vector3(Random.Range(randomMinX, randomMaxX), 0, Random.Range(randomMinZ, randomMaxZ))); }
public PoolMember SetPoolNames(PoolNames _poolNames) { poolNames = _poolNames; return(this); }