GameObject Pooler

© 2015 Freakshow Studio AS All rights reserved

Introduction

GameObject Pooler is a scripting plugin for Unity that implements a flexible and easy to use object pool.

Object pooling is essential for performance as it avoids the costly Instantiate and Destroy functions and the associated garbage that is generated and causes the garbage collector to kick in.

The Pool is simple to use, just replace your calls to Instantiate with Pool.Borrow and your calls to Destroy with Pool.Return.

Set up the items in your pool either in the editor or through code at runtime. This way you can have different items in your pool for example for each level.

Includes the possibility for logging the usage of each pool item, so you can fine-tune the number of items in your pool.

Usage

The GameObject Pooler lives in its own namespace, so in any script where you intend to use it, you first have to include the namespace. In C# you do this with using FreakLib.Pooler and in JavaScript you use import FreakLib.Pooler.

To get started right away, you can simply replace all your calls to Instantiate with Pool.Borrow, and your calls to Destroy with Pool.Return. The Pool will then automatically create these objects as pool objects for you without any further setup.

It is however recommended to add the Pool to the scene as this gives you more control over its options. Add it from the menu GameObject ⇒ Pool. You can then set the configuration options as you please, and add pool items using the 'Add PoolItem' button.

Once you have set up the pool and the items you wish to use, simply use Pool.Borrow to get an object from the pool, and Pool.Return to return an object back to the pool.

Support

For support, please contact support@freakshowstudio.com