docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ObjectPool<T>

    Generic object pool.

    Inheritance
    object
    ObjectPool<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public class ObjectPool<T> where T : new()
    Type Parameters
    Name Description
    T

    Type of the object pool.

    Constructors

    ObjectPool(UnityAction<T>, UnityAction<T>, bool)

    Constructor.

    Declaration
    public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool collectionCheck = true)
    Parameters
    Type Name Description
    UnityAction<T> actionOnGet

    Action on get.

    UnityAction<T> actionOnRelease

    Action on release.

    bool collectionCheck

    True if collection integrity should be checked.

    Properties

    countActive

    Number of active objects in the pool.

    Declaration
    public int countActive { get; }
    Property Value
    Type Description
    int

    countAll

    Number of objects in the pool.

    Declaration
    public int countAll { get; }
    Property Value
    Type Description
    int

    countInactive

    Number of inactive objects in the pool.

    Declaration
    public int countInactive { get; }
    Property Value
    Type Description
    int

    Methods

    Get()

    Get an object from the pool.

    Declaration
    public T Get()
    Returns
    Type Description
    T

    A new object from the pool.

    Get(out T)

    Get et new PooledObject.

    Declaration
    public ObjectPool<T>.PooledObject Get(out T v)
    Parameters
    Type Name Description
    T v

    Output new typed object.

    Returns
    Type Description
    ObjectPool<T>.PooledObject

    New PooledObject

    Release(T)

    Release an object to the pool.

    Declaration
    public void Release(T element)
    Parameters
    Type Name Description
    T element

    Object to release.

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)