public void CreateAndFill(out GameObject result, bool isFromPool = false, bool selfActive = true) { result = default; if (ShouldCreate()) { Surplus--; int poolIDValue = isFromPool ? poolID : int.MaxValue; result = source.Create(poolIDValue, selfActive); UniqueCache.Add(result); } else { } }
public GameObject GetUniqueCache() { int index = CacheIndex; CacheIndex++; CacheIndex = CacheIndex >= total - 1 ? 0 : CacheIndex; GameObject result = (index >= 0) && (index < UniqueCache.Count) ? UniqueCache[index] : default; if (result == default && source != default) { result = Object.Instantiate(source); UniqueCache.Add(result); total++; } else { } return(result); }