Skip to content

Latest commit

 

History

History

README.md

Object Pool & Inspector

Use ObjectPool to instantiate game objects during loading time and not during gameplay. This version allows you to have multiple pools in your game, so you can have a global one that won't be destroyed between scenes, and some level-specific ones.

object pool inspector

Usage

  1. Put the ObjectPool script in a game object that won't be destroyed during your game, and add the prefabs you want in the list in the inspector. Set the buffered amount, the default parent (optional), and you're set.
  2. To retrieve an already instantiated game object and use it in your game, use
ObjectPool.GetObjectPool("mypool").GetFromPool("myPrefabName")
  1. To pool and deactivate a previously instantiated and retrieved game object, use
ObjectPool.GetObjectPool("mypool").Pool(usedObject)

To get it persistent between scenes attach a DontDestroyOnLoad script on the same Game Object.