Click or drag to resize

PoolableObject Class

Add this component to your prefab to make it poolable.
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          (Default Namespace)PoolableObject

Namespace:  (Default Namespace)
Assembly:  AudioToolkit (in AudioToolkit.dll) Version: 8.2.0.0 (8.2.0.0)
Syntax
C#
public class PoolableObject : MonoBehaviour

The PoolableObject type exposes the following members.

Constructors
  NameDescription
Public methodPoolableObject
Initializes a new instance of the PoolableObject class
Top
Methods
  NameDescription
Public methodDeactivateAllPoolableObjectsOfMyKind
Moves all poolable objects of this kind (instantiated from the same prefab as this instance) back to the pool.
Public methodGetAllPoolableObjectsOfMyKind
Retrieves an array of all poolable objects of this kind (instantiated from the same prefab as this instance).
Public methodGetSerialNumber
Gets the object's pool serial number. Each object has a unique serial number. Can be useful for debugging purposes.
Public methodGetUsageCount
Gets the usage counter which gets increased each time an object is re-used from the pool.
Public methodIsDeactivated
Checks if the object is deactivated and in the pool.
Top
Fields
  NameDescription
Public fielddoNotDestroyOnLoad
If enabled the object will not get destroyed if a new scene is loaded
Public fieldmaxPoolSize
The maximum number of instances of this prefab to get stored in the pool.
Public fieldpreloadCount
This number of instances will be preloaded to the pool if Preload(GameObject) is called.
Public fieldsendAwakeStartOnDestroyMessage
If enabled Awake(), Start(), and OnDestroy() messages are sent to the poolable object if the object is set active respectively inactive whenever Destroy(GameObject) or Instantiate(GameObject) is called.

This way it is simulated that the object really gets instantiated respectively destroyed.

Public fieldsendPoolableActivateDeactivateMessages
If enabled a OnPoolableObjectActivated and OnPoolableObjectDeactivated message is sent to the poolable instance if the object is activated respectively deactivated by the ObjectPoolController
Top
Remarks
See ObjectPoolController for an explanation how to set up a prefab for pooling. The following messages are sent to a poolable object:
  • Awake and OnDestroy whenever a poolable object is activated or deactivated from the pool. This way the same behaviour is simulated as if the object was instantiated respectively destroyed. These messages are only sent when sendAwakeStartOnDestroyMessage is enabled.
  • OnPoolableInstanceAwake and OnPoolableInstanceDestroy when the object was actually instantiated respectively destroyed. Because of current Unity limitations OnPoolableInstanceDestroy does not work on Flash!
  • OnPoolableObjectActivated and OnPoolableObjectDeactivated whenever a poolable object is activated or deactivated from the pool. These messages are only sent when sendPoolableActivateDeactivateMessages is enabled.
See Also