docs.unity.cn
    Show / Hide Table of Contents

    Class ObjectPool<T>

    Generic object pool.

    Inheritance
    Object
    ObjectPool<T>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.Rendering
    Syntax
    public class ObjectPool<T>
        where T : new()
    Type Parameters
    Name Description
    T

    Type of the object pool.

    Constructors

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

    Constructor.

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

    Action on get.

    UnityEngine.Events.UnityAction<T> actionOnRelease

    Action on release.

    Boolean 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
    Int32

    countAll

    Number of objects in the pool.

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

    countInactive

    Number of inactive objects in the pool.

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

    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.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

    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, Boolean)
    ReflectionUtils.Invoke(Object, String, Object[])
    ReflectionUtils.SetField(Object, String, Object)
    ReflectionUtils.GetField(Object, String)
    ReflectionUtils.GetFields(Object)
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on 08 September 2023