PooledList<T> Class

Summary

A System.Collections.Generic.List`1 of active objects backed by an Weaver.ObjectPool`1 of inactive objects ready to be reused.

More detailed instructons on how to use this class and those related to it can be found at https://kybernetik.com.au/weaver/docs/misc/object-pooling.
Assembly
Weaver.dll
Namespace
Weaver
Base Types
graph BT Type-->Base0["ObjectPool<T>"] Base0-->Base1["Object"] Type["PooledList<T>"] class Type type-node

Syntax

public sealed class PooledList<T> : ObjectPool<T> where T : class

Type Parameters

Name Description
T

Constructors

Name Summary
PooledList(Func<T>, int) Creates a new Weaver.PooledList`1 which will create new items as necessary using the `createItem` delegate.

Fields

Name Constant Value Summary
ActiveObjects
The objects currently in use.

Methods

Name Value Summary
ReleaseAt(int) void
Puts an item back into the pool to be available for future use.
ReleaseRange(int, int) void
Puts a range of items back into the pool to be available for future use.

Extension Methods

Name Value Summary
ReleaseAllOnSceneUnload<T>() UnityAction<Scene>
Registers a UnityEngine.SceneManagement.SceneManager.sceneUnloaded callback to call Weaver.ObjectPool`1.ReleaseAll.

The returned delegate can be stored to later unregister from the event if necessary.
TryRelease<T>(T) bool
If the `pool` isn't null this method gives the `item` to it and returns true.