Skip to main content

Pool Manager

Pooling objects means reusing game objects instead of instantiating and destroying them every time when they are needed. As Unity's garbage collector is very performance-heavy and could result in serious hiccups and dropping frames during the game, this asset implements strict pooling (activation/deactivation) for game objects needed multiple times in one scene. Thus instantiate and destroy should be replaced by PoolManager.Spawn() and PoolManager.Despawn(). Setting up object pooling in your scene is very easy:

  • have a container game object with the PoolManager script
  • beneath this container, add one or multiple child game objects and name them as you wish
  • add the Pool script to these child game objects and enter your configuration in the inspector
  • if the prefab has a NetworkObject/PhotonView component it is considered as networked automatically

In this asset, networked PoolManager use-cases include: spawning bullets and powerups. Non-networked PoolManager uses-cases are: spawning particle effects like hit and death explosions or sound effects.