// In 2021.1 this is part of Unity #if !UNITY_2021_1_OR_NEWER namespace UnityEngine.Pool { /// /// Provides a static implementation of . /// /// Type of the objects in the pool. internal class GenericPool where T : class, new() { // Object pool to avoid allocations. internal static readonly ObjectPool s_Pool = new ObjectPool(() => new T(), null, null); /// /// Returns an object from the pool. /// /// A new object from the pool. public static T Get() => s_Pool.Get(); /// /// Get a new PooledObject which can be used to automatically return the pooled object when disposed. /// /// Output typed object. /// A new PooledObject. public static PooledObject Get(out T value) => s_Pool.Get(out value); /// /// Returns an object to the pool. /// /// Object to release. public static void Release(T toRelease) => s_Pool.Release(toRelease); } } #endif