Summary
Various utilities and extension methods for
Weaver.ObjectPool`1
.
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
-
- Object
graph BT
Type-->Base0["Object"]
Type["ObjectPool"]
class Type type-node
Syntax
public static class ObjectPool
Methods
Name | Value | Summary |
---|---|---|
CreateComponentPool |
ObjectPool |
Creates an
Weaver.ObjectPool`1 that creates new items by instantiating a specified
UnityEngine.Component . The objects will not be destroyed by scene loading.
In the Unity Editor the instantiated objects will be grouped under a common parent to keep the hierarchy
view tidy, but this step is skipped in runtime builds for efficiency.
static
|
CreateDefaultPool |
ObjectPool |
Creates an
Weaver.ObjectPool`1 that creates new items using a parameterless constructor.
static
|
CreateDefaultPool |
ObjectPool |
Creates an
Weaver.ObjectPool`1 that creates new items using a the default constructor of
T and uses a System.Collections.Generic.HashSet`1 to keep track of its
Weaver.ObjectPool`1.ActiveObjects .
static
|
CreatePrefabPool |
ObjectPool |
Creates an
Weaver.ObjectPool`1 that creates new items by instantiating a specified
UnityEngine.GameObject . The objects will not be destroyed by scene loading.
In the Unity Editor the instantiated objects will be grouped under a common parent to keep the hierarchy
view tidy, but this step is skipped in runtime builds for efficiency.
static
|
DestroyExcess |
void |
Removes and destroys items from the pool until the
System.Collections.Generic.List`1.Count reaches the
`remainingSize`.
static
|
GetCurrentPool |
ObjectPool |
Returns the pool currently creating a new item, or null at all other times.
This allows the created item's constructor to determine which pool it came from (if any).
Also registers the
Weaver.IPoolable.OnRelease of T as the
Weaver.ObjectPool`1.OnRelease callback if nothing was previously registered.
static
|
Get |
Func |
Creates a delegate that instantiates an inactive copy of the `original` object and calls
UnityEngine.Object.DontDestroyOnLoad(UnityEngine.Object) on it.
In the Unity Editor the copies are also grouped under a parent object to keep the hierarchy view clean.
static
|
Get |
Func |
Creates a delegate that instantiates an inactive copy of the `original` object and calls
UnityEngine.Object.DontDestroyOnLoad(UnityEngine.Object) on it.
In the Unity Editor the copies are also grouped under a parent object to keep the hierarchy view clean.
static
|
Get |
ObjectPool |
The first time this method is called for a particular `original` it will call
Weaver.ObjectPool.CreateComponentPool``1(``0,System.Int32,System.Boolean) and cache the returned pool so that subsequent calls using the same
`original` will return the same pool.
static
|
GetSharedPrefabPool |
ObjectPool |
The first time this method is called for a particular `original` it will call
Weaver.ObjectPool.CreatePrefabPool(UnityEngine.GameObject,System.Int32,System.Boolean) and cache the returned pool so that subsequent calls using the same
`original` will return the same pool.
static
|
Release |
UnityAction |
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.
static
|
TryRelease |
bool |
If the `pool` isn't null this method gives the `item` to it and returns true.
static
|
TryReleaseOrDestroy |
bool |
If the `pool` isn't null this method gives the `item` to it and returns true.
Otherwise this method destroys it and returns false.
Note that this method is likely not what you want to use for
UnityEngine.Component s.
Use Weaver.ObjectPool.TryReleaseOrDestroyGameObject``1(Weaver.ObjectPool{``0},``0) instead.
static
|
Try |
bool |
If the `pool` isn't null this method gives the `component` to it, disables its
UnityEngine.GameObject ,
and returns true. Otherwise this method destroys the UnityEngine.GameObject and returns false.
static
|
Try |
bool |
If the `pool` isn't null this method releases the `component` to it, disables its
UnityEngine.GameObject ,
and returns true. Otherwise this method destroys the UnityEngine.GameObject and returns false.
static
|
Try |
bool |
If the `behaviour` was created by an
Weaver.ObjectPool`1 this method releases the `behaviour` to
it, disables its UnityEngine.GameObject , and returns true.
Otherwise this method destroys the UnityEngine.GameObject and returns false.
static
|