Download this documentation page as a PDF.

Contents

PlayMaker

A PlayMaker integration library is included with Pure Pool, to help you use object pooling in your FSMs, without needing any programming knowledge. Please follow the installation instructions for the integration library before continuing.

General Usage

The integration script adds the following PlayMaker actions to Unity:

  • Acquire Component
    • Acquires an instance of a Component from a pool.
  • Acquire Game Object
    • Acquires an instance of a GameObject from a pool.
  • Acquire Game Object From Manager
  • Create Component Pool
    • Creates a new ComponentPool pool.
  • Create Game Object Pool
    • Creates a new GameObjectPool pool.
  • Initialise Pool
    • Initialises a GameObject pool.
  • Release Component
    • Releases an instance of a Component to its pool.
  • Release Game Object
    • Releases an instance of a GameObject to its pool.
  • Release Game Object To Manager
    • Releases an instance of a GameObject to its pool using a pool manager.
  • Release Game Objects To Manager
    • Releases an array of GameObject instances to their appropriate pools, using a pool manager. The GameObjects in the array do not have to be of the same type, and do not need to have originated from the same pool.

Acquire Game Object From Manager

The Acquire Game Object From Manager action is the easiest way to obtain a pooled object.

The Pool Manager property can be set to the GameObjectPoolManager that you intend to use. If it's set to None, the first GameObjectPoolManager component in the scene will be used. If there isn't one in the scene, a new one will be created with default values. For full control, manually add a GameObjectPoolManager component to any GameObject in the scene - you can do this quickly using the GameObject -> Pooling -> GameObject Pool Manager menu item.

The Prefab variable should be set to the GameObject or prefab that you'd like to obtain an instance (pooled copy) of.

The Parent property is optional, and if specified, will be used as the parent of the GameObject taken from the pool.

The Position property is also optional, and can be set to a variable with value None if you want to use the position of the Prefab. If you do specify the position, it will be relative to the position of the Prefab - if you're spawning things in the wrong place, ensure the Prefab has a position of 0,0,0.

The Rotation property is optional, and can be set to a variable with value None if you want to use the rotation of the Prefab. If you specify the rotation, it will override the rotation of the Prefab.

The Instance variable will contain the GameObject that was acquired from the pool, but you can set it to None if you don't need to use it. Storing the instance can be useful to release the object back to the pool when it's no longer required.

Release Game Object To Manager

Complementary to the Acquire action, the Release Game Object To Manager action is the easiest way to return a pooled object.

The Pool Manager property can be set to the GameObjectPoolManager that you intend to use. If it's set to None, the first GameObjectPoolManager component in the scene will be used. If there isn't one in the scene, a new one will be created with default values - however, this wouldn't be very helpful here, as you can't release to it if there's no pool. For full control, manually add a GameObjectPoolManager component to any GameObject in the scene - you can do this quickly using the GameObject -> Pooling -> GameObject Pool Manager menu item. Use the same manager as you use in the Acquire Game Object From Manager action.

The Instance variable should contain the GameObject that was acquired from the pool, and that you wish to release back to the pool.