/// <summary> /// Dispose of the cached component filter /// </summary> /// <param name="disposing">Whether or not to dispose the contents of this object</param> protected virtual void Dispose(bool disposing) { if (m_DisposedValue) { return; } if (disposing && m_MasterComponentStorage != null) { CollectionPool <List <TFilterType>, TFilterType> .RecycleCollection(m_MasterComponentStorage); } m_DisposedValue = true; }
/// <summary> /// Remove UnityObjects from a dictionary which have been destroyed /// </summary> /// <typeparam name="T">The specific type of UnityObject in the dictionary</typeparam> /// <param name="list">A dictionary of UnityObjects that may contain destroyed objects</param> public static void RemoveDestroyedObjects <T>(List <T> list) where T : UnityObject { var removeList = CollectionPool <List <T>, T> .GetCollection(); foreach (var component in list) { if (component == null) { removeList.Add(component); } } foreach (var entry in removeList) { list.Remove(entry); } CollectionPool <List <T>, T> .RecycleCollection(removeList); }
/// <summary> /// Remove UnityObjects keys from a dictionary which have been destroyed /// </summary> /// <typeparam name="TKey">The specific type of UnityObject in the dictionary</typeparam> /// <typeparam name="TValue">The value type of the dictionary</typeparam> /// <param name="dictionary">A dictionary of UnityObjects that may contain destroyed objects</param> public static void RemoveDestroyedKeys <TKey, TValue>(Dictionary <TKey, TValue> dictionary) where TKey : UnityObject { var removeList = CollectionPool <List <TKey>, TKey> .GetCollection(); foreach (var kvp in dictionary) { var key = kvp.Key; if (key == null) { removeList.Add(key); } } foreach (var key in removeList) { dictionary.Remove(key); } CollectionPool <List <TKey>, TKey> .RecycleCollection(removeList); }