/// <summary> /// Releases all currently spawned objects of all types. /// </summary> public void ReleaseAll() { foreach (KeyValuePair <string, FactoryData> itm in mFactory) { FactoryData factory = itm.Value; for (int i = 0; i < factory.actives.Count; i++) { PoolDataController pdc = factory.actives[i]; pdc.SendMessage(OnDespawnMessage, null, SendMessageOptions.DontRequireReceiver); factory.Release(pdc, false); } factory.actives.Clear(); } }
/// <summary> /// Release all currently spawned objects based on given type. /// </summary> public void ReleaseAllByType(string type) { FactoryData factory; if (mFactory.TryGetValue(type, out factory)) { for (int i = 0; i < factory.actives.Count; i++) { PoolDataController pdc = factory.actives[i]; pdc.SendMessage(OnDespawnMessage, null, SendMessageOptions.DontRequireReceiver); factory.Release(pdc, false); } factory.actives.Clear(); } else { Debug.LogWarning("Unable to find type: " + type); } }