ComponentPoolManager Class |
[This is preliminary documentation and is subject to change.]
Namespace: Umbrace.Unity.PurePool
public class ComponentPoolManager : PoolManagerBase<ComponentPoolManagerSettings, ComponentPool, ComponentPoolSettings, Type, Component>
The ComponentPoolManager type exposes the following members.
Name | Description | |
---|---|---|
ComponentPoolManager | Initializes a new instance of the ComponentPoolManager class |
Name | Description | |
---|---|---|
AcquireMode |
Gets or sets the way in which to handle attempts to acquire an object, for which no pool exists.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
AttachDescendentPools |
Gets or sets value indicating whether to attach all descendent pools to the manager on startup.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
DefaultPoolSettings |
Gets the settings that are used when a new pool is created.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
DontDestroyOnLoad |
Gets or sets a value indicating whether the pool manager (and the pools beneath it) will remain in the scene when a new scene is loaded.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Enabled |
Gets or sets a value indicating whether pooling is enabled.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Instance |
Gets the ComponentPoolManager found in the scene.
| |
ObjectPools |
When overridden in a derived class, gets the internal object pool dictionary, mapping from the source object to its pool.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceObjectPools.) | |
PoolCount |
Gets the number of pools attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Pools |
Gets the collection of pools attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) |
Name | Description | |
---|---|---|
Acquire(TSource) |
Acquires an instance of source from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Acquire(Type, Transform) |
Acquires an instance of componentType from an attached pool, and sets its parent transform.
| |
Acquire(Type, Vector3, Quaternion) |
Acquires an instance of componentType from an attached pool, and sets its position and rotation.
| |
Acquire(Type, Transform, Vector3, Quaternion) |
Acquires an instance of componentType from an attached pool, and sets its parent transform, position and rotation.
| |
AcquireT |
Acquires an instance of the component T from an attached pool.
| |
AcquireT(Transform) |
Acquires an instance of the component T from an attached pool, and sets the parent transform of its GameObject.
| |
AcquireT(Vector3, Quaternion) |
Acquires an instance of the component T from an attached pool, and sets the position and rotation of its GameObject.
| |
AcquireT(Transform, Vector3, Quaternion) |
Acquires an instance of the component T from an attached pool, and sets the parent transform, position and rotation of its GameObject.
| |
AttachPool |
Attaches the specified pool to the manager, allowing the manager to acquire and release instances from it.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Awake | (Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
CanAcquire |
Determines whether an instance of sourceObject can be acquired from its pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
CreatePool(Type) |
Creates a ComponentPool that pools instances of componentType, and attaches it to the manager.
The pool is created on a child object of the manager's game object.
| |
CreatePool(TPoolSettings) |
Creates a new pool using the specified settings, and attaches it to the manager.
The pool is created on a child object of the manager's game object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
CreatePool(Type, GameObject, Boolean) |
Creates a ComponentPool that pools instances of componentType, and attaches it to the manager.
| |
CreatePool(TPoolSettings, GameObject, Boolean, String) |
Creates a new pool using the specified settings, and attaches it to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
DestroyPool |
Destroys the specified pool that's attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
DetachPool |
Detaches the specified pool from the manager, without destroying it.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
FindChildPools |
Finds all pools that are parented to the manager's game object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
GetHashCode | (Inherited from Object.) | |
GetPool |
Gets the pool that handles instances of the specified source object.
The manager must contain a matching pool to use this method.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
GetPooledCount |
Gets the number of instances of the specified object contained in the pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
GetSourceName |
When implemented in a derived class, gets the name of the specified source.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceGetSourceName(TSource).) | |
GetType | (Inherited from Object.) | |
HasPool |
Determines whether the manager has a pool that handles instances of the specified source object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
InternalAcquire |
When implemented in a derived class, attempts to acquire an instance of a source according to AcquireMode.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceInternalAcquire(TSource, TPool, TInstance).) | |
IsAttached |
Determines whether the specified pool is attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
IsPoolEmpty |
Determines whether the pool is empty for instances of the specified object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
MemberwiseClone | (Inherited from Object.) | |
OnPoolAttached |
Raises the PoolAttached event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
OnPoolCreated |
Raises the PoolCreated event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
OnPoolDestroyed |
Raises the PoolDestroyed event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
OnPoolDetached |
Raises the PoolDetached event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
Release |
Releases an instance that was previously acquired from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
ReleaseInternal |
Releases an instance of a component that was previously acquired from an attached pool.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceReleaseInternal(TInstance).) | |
ToString | (Inherited from Object.) | |
TryAcquire(TSource, TInstance) |
Acquires an instance of sourceObject from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
TryAcquire(Type, Transform, Component) |
Acquires an instance of componentType from an attached pool, and sets its parent transform.
| |
TryAcquire(Type, Vector3, Quaternion, Component) |
Acquires an instance of componentType from an attached pool, and sets its position and rotation.
| |
TryAcquire(Type, Transform, Vector3, Quaternion, Component) |
Acquires an instance of componentType from an attached pool, and sets its parent transform, position and rotation.
| |
TryAcquireT(T) |
Acquires an instance of the component T from an attached pool.
| |
TryAcquireT(Transform, T) |
Acquires an instance of the component T from an attached pool, and sets the parent transform of its GameObject.
| |
TryAcquireT(Vector3, Quaternion, T) |
Acquires an instance of the component T from an attached pool, and sets the position and rotation of its GameObject.
| |
TryAcquireT(Transform, Vector3, Quaternion, T) |
Acquires an instance of the component T from an attached pool,, and sets the parent transform, position and rotation of its GameObject.
| |
TryGetPool |
Gets the pool that handles instances of the specified source object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) |
Name | Description | |
---|---|---|
PoolAttached |
Occurs when a GameObjectPool is attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
PoolCreated |
Occurs when a GameObjectPool is created by the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
PoolDestroyed |
Occurs when a GameObjectPool is destroyed by the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) | |
PoolDetached |
Occurs when a GameObjectPool is detached from the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.) |
// Create the manager as a component on a game object. var manager = gameObject.AddComponent<ComponentPoolManager>(); // Set up the manager's properties. manager.DontDestroyOnLoad = true; manager.AttachDescendentPools = true; manager.AcquireMode = AcquireNoPoolMode.CreatePool; // Attach an existing pool to the manager. manager.AttachPool(pool); // Create a pool that is attached to the manager. manager.CreatePool(new ComponentPoolSettings { Source = typeof(AudioSource), DontDestroyOnLoad = true, Enabled = true, InitialiseOnStart = true, InitialSize = 10, InstantiateWhenEmpty = true, LogMessages = LogLevel.Warning, MaximumSize = 50, NotificationMode = NotificationMode.Interface, RecordStatistics = true, ReparentPooledObjects = true }); // Acquire an AudioSource instance from the manager. The Acquire method can be used safely if the AudioSource pool's InstantiateWhenEmpty property is true, or if a check is made to CanAcquire beforehand. AudioSource instance = manager.Acquire<AudioSource>(); // Acquire another AudioSource instance from the manager. TryAcquire can be used safely even when InstantiateWhenEmpty is false. AudioSource secondInstance; if (manager.TryAcquire(out secondInstance)) { // Release the component back to the manager. manager.Release(secondInstance); } // Release the component back to the manager. manager.Release(instance);