Click or drag to resize

GameObjectPoolManager Class

[This is preliminary documentation and is subject to change.]

Manages a collection of GameObjectPool components, simplifying access to the pools and allowing for automatic pool creation.
Inheritance Hierarchy
SystemObject
  UnityEngineObject
    UnityEngineComponent
      UnityEngineBehaviour
        UnityEngineMonoBehaviour
          Umbrace.Unity.PurePoolPoolManagerBaseGameObjectPoolManagerSettings, GameObjectPool, GameObjectPoolSettings, GameObject, GameObject
            Umbrace.Unity.PurePoolGameObjectPoolManager

Namespace:  Umbrace.Unity.PurePool
Assembly:  Umbrace.Unity.PurePool (in Umbrace.Unity.PurePool.dll) Version: 0.0.0.0 (1.0.0.0)
Syntax
C#
public class GameObjectPoolManager : PoolManagerBase<GameObjectPoolManagerSettings, GameObjectPool, GameObjectPoolSettings, GameObject, GameObject>

The GameObjectPoolManager type exposes the following members.

Constructors
  NameDescription
Public methodGameObjectPoolManager
Initializes a new instance of the GameObjectPoolManager class
Top
Properties
  NameDescription
Public propertyAcquireMode
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.)
Public propertyAttachDescendentPools
Gets or sets value indicating whether to attach all descendent pools to the manager on startup.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public propertyDefaultPoolSettings
Gets the settings that are used when a new pool is created.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public propertyDontDestroyOnLoad
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.)
Public propertyEnabled
Gets or sets a value indicating whether pooling is enabled.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public propertyStatic memberInstance
Gets the GameObjectPoolManager found in the scene.
Protected propertyObjectPools
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.)
Public propertyPoolCount
Gets the number of pools attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public propertyPools
Gets the collection of pools attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Top
Methods
  NameDescription
Public methodAcquire(TSource)
Acquires an instance of source from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodAcquire(GameObject, Transform)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform.
Public methodAcquire(GameObject, Transform, Boolean)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform.
Public methodAcquire(GameObject, Vector3, Quaternion)
Acquires an instance of sourceObject from an attached pool, and sets its position and rotation.
Public methodAcquire(GameObject, Vector3, Quaternion, Transform)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform, position and rotation.
Public methodAttachPool
Attaches the specified pool to the manager, allowing the manager to acquire and release instances from it.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodAwake (Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodCanAcquire
Determines whether an instance of sourceObject can be acquired from its pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodCreatePool(GameObject)
Creates a GameObjectPool that pools instances of sourceObject, and attaches it to the manager. The pool is created on a child object of the manager's game object.
Public methodCreatePool(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.)
Public methodCreatePool(GameObject, GameObject, Boolean)
Creates a GameObjectPool that pools instances of sourceObject, and attaches it to the manager.
Public methodCreatePool(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.)
Public methodDestroyPool
Destroys the specified pool that's attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodDetachPool
Detaches the specified pool from the manager, without destroying it.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodFindChildPools
Finds all pools that are parented to the manager's game object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetPool
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.)
Public methodGetPooledCount
Gets the number of instances of the specified object contained in the pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodGetSourceName
When implemented in a derived class, gets the name of the specified source.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceGetSourceName(TSource).)
Public methodGetType (Inherited from Object.)
Public methodHasPool
Determines whether the manager has a pool that handles instances of the specified source object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodInternalAcquire
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).)
Public methodIsAttached
Determines whether the specified pool is attached to the manager.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodIsPoolEmpty
Determines whether the pool is empty for instances of the specified object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnPoolAttached
Raises the PoolAttached event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodOnPoolCreated
Raises the PoolCreated event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodOnPoolDestroyed
Raises the PoolDestroyed event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodOnPoolDetached
Raises the PoolDetached event.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodRelease
Releases an instance that was previously acquired from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Protected methodReleaseInternal
Releases an instance of a game object that was previously acquired from an attached pool.
(Overrides PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstanceReleaseInternal(TInstance).)
Public methodToString (Inherited from Object.)
Public methodTryAcquire(TSource, TInstance)
Acquires an instance of sourceObject from an attached pool.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Public methodTryAcquire(GameObject, Transform, GameObject)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform.
Public methodTryAcquire(GameObject, Transform, Boolean, GameObject)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform.
Public methodTryAcquire(GameObject, Vector3, Quaternion, GameObject)
Acquires an instance of sourceObject from an attached pool, and sets its position and rotation.
Public methodTryAcquire(GameObject, Vector3, Quaternion, Transform, GameObject)
Acquires an instance of sourceObject from an attached pool, and sets its parent transform, position and rotation.
Public methodTryGetPool
Gets the pool that handles instances of the specified source object.
(Inherited from PoolManagerBaseTManagerSettings, TPool, TPoolSettings, TSource, TInstance.)
Top
Events
Examples
C#
// Create the manager as a component on a game object.
var manager = gameObject.AddComponent<GameObjectPoolManager>();

// 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 GameObjectPoolSettings {
    Source = myPrefab,
    DontDestroyOnLoad = true,
    Enabled = true,
    InitialiseOnStart = true,
    InitialSize = 10,
    InstantiateWhenEmpty = true,
    LogMessages = LogLevel.Warning,
    MaximumSize = 50,
    NotificationMode = NotificationMode.Interface,
    RecordStatistics = true,
    ReparentPooledObjects = true
});

// Acquire an instance of myPrefab from the manager. The Acquire method can be used safely if the myPrefab pool's InstantiateWhenEmpty property is true, or if a check is made to CanAcquire beforehand.
GameObject instance = manager.Acquire(myPrefab);

// Acquire another myPrefab instance from the manager. TryAcquire can be used safely even when InstantiateWhenEmpty is false.
GameObject secondInstance;
if (manager.TryAcquire(myPrefab, out secondInstance)) {
    // Release the instance back to the manager.
    manager.Release(secondInstance);
}

// Release the instance back to the manager.
manager.Release(instance);
See Also