Click or drag to resize

NamedGameObjectPoolManager Class

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

Provides named access to the pools of a GameObjectPoolManager.
Inheritance Hierarchy
SystemObject
  UnityEngineObject
    UnityEngineComponent
      UnityEngineBehaviour
        UnityEngineMonoBehaviour
          Umbrace.Unity.PurePoolNamedGameObjectPoolManager

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 NamedGameObjectPoolManager : MonoBehaviour, 
	ISerializationCallbackReceiver

The NamedGameObjectPoolManager type exposes the following members.

Constructors
  NameDescription
Public methodNamedGameObjectPoolManager
Initializes a new instance of the NamedGameObjectPoolManager class
Top
Properties
  NameDescription
Public propertyAssignedNames
Gets a list of the names currently assigned to game objects.
Public propertyAutoAddFromManager
Gets or sets a value indicating whether to automatically provide named access to the pools attached to the manager.
Public propertyStatic memberInstance
Gets the NamedGameObjectPoolManager found in the scene.
Public propertyItem
Gets the pool that handles instances of the source object with the specified name. The manager must contain a matching pool to use this method.
Public propertyManager
Gets or sets the pool manager whose pools should be accessed by name.
Public propertyUseResources
Gets or sets a value indicating whether to attempt to locate unrecognised names using Load(String).
Top
Methods
  NameDescription
Public methodAcquire(String)
Acquires an instance of the source object with the specified name, from an attached pool.
Public methodAcquire(String, Transform)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform.
Public methodAcquire(String, Transform, Boolean)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform.
Public methodAcquire(String, Vector3, Quaternion)
Acquires an instance of the source object with the specified name from an attached pool, and sets its position and rotation.
Public methodAcquire(String, Vector3, Quaternion, Transform)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform, position and rotation.
Public methodCanAcquire
Determines whether an instance of the source object with the specified name can be acquired from its pool.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetGameObject
Gets the GameObject that is currently assigned the specified name.
Public methodGetHashCode (Inherited from Object.)
Public methodGetName
Gets the name that is currently assigned to the specified GameObject.
Public methodGetPool
Gets the pool that handles instances of the source object with the specified name. The manager must contain a matching pool to use this method.
Public methodGetPooledCount
Gets the number of instances of the object with the specified name contained in the pool.
Public methodGetType (Inherited from Object.)
Public methodHasName(String)
Determines whether the specified name is currently assigned.
Public methodHasName(GameObject)
Determines whether the specified GameObject is currently assigned a name.
Public methodHasPool
Determines whether the manager has a pool that handles instances of the source object with the specified name.
Public methodIsPoolEmpty
Determines whether the pool is empty for instances of the object with the specified name.
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnChanged
Raises the Changed event.
Public methodRelease
Releases an instance of a game object that was previously acquired from a pool.
Public methodRemoveName(String)
Removes the specified named access.
Public methodRemoveName(GameObject)
Removes the named access to the specified GameObject.
Public methodSetName
Assigns a name to the specified GameObject.
Public methodToString (Inherited from Object.)
Public methodTryAcquire(String, GameObject)
Acquires an instance of the source object with the specified name, from an attached pool.
Public methodTryAcquire(String, Transform, GameObject)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform.
Public methodTryAcquire(String, Transform, Boolean, GameObject)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform.
Public methodTryAcquire(String, Vector3, Quaternion, GameObject)
Acquires an instance of the source object with the specified name from an attached pool, and sets its position and rotation.
Public methodTryAcquire(String, Vector3, Quaternion, Transform, GameObject)
Acquires an instance of the source object with the specified name from an attached pool, and sets its parent transform, position and rotation.
Public methodTryGetGameObject
Gets the GameObject that is currently assigned the specified name.
Public methodTryGetName
Gets the name that is currently assigned to the specified GameObject.
Public methodTryGetPool
Gets the pool that handles instances of the source object with the specified name.
Top
Events
  NameDescription
Public eventChanged
Occurs when the collection of named pools is changed.
Top
Remarks
Unlike GameObjectPoolManager, which uses object references to refer to the source object you wish to acquire an instance of, NamedGameObjectPoolManager instead uses a String name to refer to the source object.
Examples
C#
// Create the component on a game object.
var byName = gameObject.AddComponent<NamedGameObjectPoolManager>();

// Set up the properties.
byName.Manager = manager;
byName.AutoAddFromManager = true;

// Assign custom names to the objects being pooled.
byName.SetName(prefab, "Asteroid_1");

// Acquire an instance of the "prefab" object, using its string name.
var instance = byName.Acquire("Asteroid_1");

// Access the GameObjectPool that stores the "prefab" instances.
GameObjectPool asteroidPool = byName["Asteroid_1"];

// Release the acquired instance back to the pool.
byName.Release(instance);
See Also