PoolManager [By Path-o-logical-Games]

PoolManager 4
By Path-o-logical Games, the makers of TargetPRO and UnityConstraints

We are proud to announce this easier, more flexible, version of PoolManager. Now with support for Unity 4 (and still backwards compatible with Unity 3x) and Shuriken particle systems (auto-despawn when all particles die) !

Please check out the PoolManager website for a full list of features and the following video introduction: http://PoolManager.path-o-logical.com

PoolManager is currently priced at $30 (and it isn’t going to get cheaper ). (PayPal Accepted)

Note you can watch this video in HD…

Why Use Pooling?
When instances of a Prefab are needed over and over, it is more efficient to only create one, and instead of destroying it, reuse it. This is referred to as ā€˜instance pooling’; where you take an item from the pool first and only create new instances if none are available. Most importantly, Destroy() has been reported to be the worst part of the instance/destroy paradigm, causing garbage collection stutters (momentary freezing every 10 seconds or so). Pooling removes the Destroy() entirely.

We spent a lot of time thinking about ways to avoid intense tasks during game-play so you don’t have to.

What we didn’t expect is that we would find ourselves using PoolManager on objects which don’t need pooling just to use the organizational features! Pre-loading, automatic scene hierarchy organization, debugging messages and static access to lists of objects in the scene are all valuable on their own.

If you have any questions please stop by our forums at http://support.path-o-logical.com/forums or email support@path-o-logical.com.

Release Notes
http://forums.support.path-o-logical.com/viewtopic.php?f=3&t=31

Thank you for your interest. We hope to see you on the forums!

Ā© 2011 Path-o-logical Games. All rights reserved.

Does this just speed up destroying and instantiating? I do most of mine at the start of the levels, is this more for bullets ect rather than general one time loading?

Good questions! Thanks for asking…

It doesn’t speed up destroying or Instancing, it eliminates it except for when you want it to happen or if it is absolutely necessary. The only time PoolManager will create a new instance is if it doesn’t have any to reuse. You can preload instances when the game starts, or when you add a pool to the game, so that you create a bunch and then reuse them later. More instances will be created only if all the current instances are in use (spawned). Destroy is only called if you choose to make it happen by destroying a whole pool or by using the automatic culling feature. If you were to reload a scene, it would destroy everything automatically from the old scene and preload (optional) everything in the new scene. This is quite robust in PoolManager2.

When an instance is available to be spawned, the Spawn() method basically just activates the instance and passes around a couple of reference which are cached. It is extremely fast.

There are other features which are nice as well and just make it easier to work with instances.

PoolManager works great for both situations. We use it for both in our own game development. For example, I have some 3D icons that I am using PoolManager to preload and give me easy static access even though i am only ever using one instance and the objects are very simple (one is just a cube), it is just convenient.

On the other side of the spectrum, we use PoolManager for tons of life bars, explosions, flashes on sprites and particle systems (there is handling for one-shot particles that despawn automatically).

So we use Poolmanager for really anything. I think the only thing I am not using it for is when I make a clone of an object in the scene to strip it back and make it an icon in a HUD. Oh, and the base of our towers (TD game) is a simple structure they all share, so when I spawn a tower I just instance a base directly and make it a permanent child of the spawn. Once it is a child, it is automatically handled by PoolManager when the parent Tower is destroyed and spawned again.

I hope that makes sense and answers your question.

Thanks for your answers :slight_smile: I think that this means it wont actually speed up my game as it still has to load all the objects at the start of the game, (which is what im doing anyway). Once the games tested on slower phones I might have to give it a try, otherwise I will definitely be needing this for my next project, so will grab it then :smile:

Sure thing! It sounds like you have a well thought-out setup for your current game. It is really just the caching and Destroy() you need to watch out for then, at least on mobile devices. I’ll let you know in advance if we decide to raise prices before you start your next game :p… Good luck!

how would I go about storing a reference to the prefab used in a SpawnPool. GetPrefab() seems to do the opposite, afaik.

I’m attempting, during runtime, to store a reference to the prefab used in the ā€œprefabā€ field of an individual spawnPool. Any assistance would be greatly appreciated.

PS, when is UnityConstraints due for release? It looks interesting

GetPrefab is for when you have a reference to an instance and need a reference to the instance’s prefab.

That is a very interesting idea. First, a SpawnPool could have many prefab pools, so it would have to a be a list or dict. You know, I could easily do this, but I would need more information. For example, how you would get it, by string name? So, if I had an ā€œEnemiesā€ pool with a ā€œZombieā€ and a ā€œNinjaā€ prefab dropped in to the Inspector, and I also have a ā€œPirateā€ which isn’t (just in the project, but not dropped in the inspector) then I would do something like…

SpawnPool pool = PoolManager.Pools["Enemies"];

Transform zombiePrefab = pool.prefabs["Zombie"];
Transform zombieInstance = pool.Spawn(zombiePrefab);

Transform ninjaPrefab = pool.prefabs["Ninja"];
Transform ninjaInstance = pool.Spawn(zombiePrefab);

// Creates a prefab pool the first time a Pirate is instanced
Transform firstPirateInstance = pool.spawn(piratePrefabReference); 

// From then on, in any script, you could do...
Transform piratePrefab = pool.prefabs["Pirate"];
Transform pirateInstance = pool.Spawn(zombiePrefab);

This would be a dictionary so the look-up would be superfast, no string comparing needed.

WDYT?

A quick aside here… I hope I didn’t confuse things there at the end. I’m just trying to say that Spawn() will create a prefab pool automatically if you don’t make one in the inspector. The inspector is optional, but an easy way to setup preloading, etc. In our game we have a whole pool of 2D image-icons which I don’t drag&drop, so I literally just added a SpawnPool component to a GameObject and named the GameObject ā€œIconsPoolā€ and that is it! I actually preload them another way, so, same result really. I am bringing this up to remind everyone there are more ā€œlazyā€ ways to create a PrefabPool when you have a lot of prefabs. You can make a quick script when drag and drop goes from convenient to tedious.

Back to the code above… This is a form of hard-coding though, since you now need the string to always match the name of the prefab, but it could be handy in some cases, and there really isn’t any overhead, so why not…

Shhhh, it’s out now but not officially until I make videos =)
http://Packages.path-o-logical.com
It is free, and you can download it from the features page there. It won’t stay free either, but we have no time-frame yet. A month at least. At least until I have time to add a few more things.

@Rafes, thank you tons for the assistance :-), and the link to UnityConstraints, another BIG timesaver! So glad you went with coroutines there instead of update loops. We’re converting nearly all of our update loops to Coroutines, much nicer on CPU :slight_smile:

I could really use the functionality you sketched out above, nicely thought out. the ability to ā€œTransform zombiePrefab = pool.Prefabs[ā€œPiratePrefabā€];ā€ would be sooooooo useful. I’m having to go through a few hoops to get something similar, but could really use this as core functionality in PoolManager. In the cases I’m using now, I now all the string names of the pools in advance, so that would definitely work imo.

Fingers crossed its included in a future build, I started hacking the poolmanager.cs, but had to get back on task, so perhaps you’ll beat me to it :wink:

That code is now real code. PoolManager2.1 is submitted to the asset store (release note added in OP with link to docs) :sunglasses:

I have your email address so I’ll send you a copy after dinner.

Enjoy!

EDIT: (I added this to the OP too) Docs: https://sites.google.com/a/path-o-logical.com/poolmanager2-docs/code-reference/spawnpool/prefabs

WHOA!!! now that was amazingly fast!
Thank you VERY much for such a quick addition of (what we consider) a necessary feature for our pipeline.

Testing time :wink:

IF YOU USE POOLS IN YOUR PROJECTS(and you REALLY should for any mobile development), YOU NEED POOLMANAGER! Get it in the asset Store ASAP.

top notch product, top notch support!

EDIT: Just tested out the new functionality, works perfectly! thank you :slight_smile:

Released Version 2.1.1. Minor fix. See notes in OP.

I’m going to be giving PoolManager an custom inspector face-lift soon. The new interface won’t effect on your code or change the basic layout. It will just look a little better.

While I’m in there, does anyone have any requests?

Our forums have finally been transferred to their permanent home. Here is a post about it:
http://forums.support.path-o-logical.com/viewtopic.php?f=3&t=16

I am also going to change the release information in the original thread above to be a link to a forums announcement thread so we don’t have to update multiple places (It is so nice to be able to link to things…finally!)

I would like to know if using PoolManager in my project (essentiallly it is a third person shooter with a lot of instance and destroy functions for bullets, enemies, explosions, etc.) I am going to get significant and noticeable better framerates?
Thanks.

On mobile devices, absolutely. On Desktops it depends a lot more on the specifics of your game. Many users have reported improvements. I have personally had trouble with Garbage Collection stutters, which PoolManager fixed.

All I can say for sure is that PoolManager definitely reduces the work your game has to do when you need performance most The features that it provides are handy and if your game is already running with Instantiate() and Destroy() it will only take you a few minutes to import PoolManager and switch over (depending on the complexity of your needs of course, but you would just search and manually replace Unity’s function with PoolManager’s)

I hope that helps. It is a hard question to reply to.

We have a new release coming with a custom interface that will make it very easy to keep things compact and much easier to find and work with! I hope to release this over the weekend. In the mean time, does anyone have any feature requests or feedback?

Cheers,

Hey, it looks like a cool script! I had done something with object pooling a long time back that got fairly hairy after getting into the project. I had EVERYTHING pooled including particle effects…(although I’m not too sure about the usefulness of that.)
It looks like you guys have ironed out alot of the issues I was having way back when. I’ll pick this up soon.

One request for your other product…It would be nice to incorporate a Perlin noise function into your look at constraints. Then we could have baddies that have taken damage not be so accurate when they take aim to shoot at you! You could add in an ā€˜accuracy’ percentage. If I get some time, I’ll see if I can scare up something for this.

Thanks!
-Patrick

Thanks for the comments Patrick. UnityConstraints is getting a face lift too and I do want to add some more advanced features (it won’t be free when i do though). One addition to the Smooth Look-At constraint I am working on now is target leading, using trajectory or way-points, so you can have a ballistic or gun fire where a target is going to be, for example.

Your idea is fun! You can do something like that now if you want. Instead of setting the target, use a script to get the targets position, apply the noise, then set the constraint’s internal position. This is not the normal transform.position. The Constraint.position is the internal position of the ā€œtargetā€. This means the SmoothLookAt constraint doesn’t need an actual target GameObject, you can set it by script (there is actually a ā€œnoTargetModeā€ in the Inspector that you can set to ā€œsetByScriptā€ to allow this.)

I just need to get some time to document these additions and make some videos.

(The boards won’t let me edit my post for some reason. I forgot to mention…)

BTW, I’m using PoolManager for ParticleEmitters and it works great. I’ve even done a comet-style-trail that automatically despawns once I turn off the trail emitter and all particles die.

Version 2.5 Released!
(Submitted to the asset store today)

Full Release Notes: http://support.path-o-logical.com/forums
New Inspector Interface!: (Docs) http://docs.poolmanager.path-o-logical.com/home/per-prefab-options