public static bool EnqueueInstance(GameObject instance, PoolDescription poolDescription) { if (!Instance) { return(false); } return(Instance.EnqueueInstanceImpl(instance, poolDescription)); }
public static void CreatePool(PoolDescription poolDescription) { if (!Instance) { return; } Instance.CreatePoolImpl(poolDescription); }
public void AddPool(PoolDescription newPool) { if (newPool != null && !IsPoolCreated(newPool.name)) { newPool.pool = new ObjectPool(newPool.name, newPool.masterPrefab, newPool.size, newPool.allowRuntimeCreation); pools.Add(newPool); } }
// Use this for initialization void Start() { PoolDescription pool = new PoolDescription(); pool.name = bulletPrefab.name; pool.category = "Ammo"; pool.masterPrefab = bulletPrefab; pool.size = 100; pool.allowRuntimeCreation = true; PoolManager.Instance.AddPool(pool); }
public void ReleaseObjectFromPool(string name, GameObject toReleaseObject, bool sendMessage) { if (toReleaseObject != null && sendMessage) { toReleaseObject.BroadcastMessage("ReleaseObject", SendMessageOptions.DontRequireReceiver); } PoolDescription pd = GetPoolDescription(name); if (pd != null) { pd.pool.ReleaseObject(toReleaseObject); return; } Debug.LogWarning("PoolManager::ReleaseObjectFromPool -- Can't find the pool: " + name); }
private void ListPools() { try { PoolDescription pool = service.ChooseOption("Choose an Azure Batch Pool", new AsyncLazy <PoolDescription[]>(() => manager.GetAvailablePools()), new Predicate <PoolDescription>(p => p.Id == selectedPool)); if (pool != null) { Pool = pool.Id; } } catch (Exception ex) { service.ShowError(ex, "Failed to get list of available Azure Batch pools"); } }
public GameObject GetObjectFromPool(string name, GameObject masterPrefab, bool sendInitMessage) { GameObject go = null; PoolDescription pd = pools.Find( item => String.Compare(item.name, name, 0) == 0); if (pd != null) { go = pd.pool.GetObject(); if (sendInitMessage) { go.BroadcastMessage("InitObject", SendMessageOptions.DontRequireReceiver); } return(go); } // If we get here the pool just doesn't exist ... if (masterPrefab != null) { PoolDescription newPool = new PoolDescription(); newPool.size = 0; newPool.masterPrefab = masterPrefab; newPool.name = name; newPool.pool = new ObjectPool(name, masterPrefab, 1, true); AddPool(newPool); go = newPool.pool.GetObject(); if (sendInitMessage) { go.BroadcastMessage("InitObject", SendMessageOptions.DontRequireReceiver); } Debug.LogWarning(name + " wasn't created. Please add a PoolDescription specifying the initial size."); return(go); } return(null); }
protected abstract bool EnqueueInstanceImpl(GameObject instance, PoolDescription poolDescription);
protected abstract void CreatePoolImpl(PoolDescription poolDescription);