Search Unity

Pooly - Professional Pooling System

Discussion in 'Assets and Asset Store' started by sharkyro, Mar 7, 2017.

  1. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Pooly_Facebook-@1200x630.png
    Pooly on the Asset Store can be found here.

    Instantiating and destroying a lot of items (such as bullets or enemies) is inefficient and can slow down your projects. A professional way of handling this issue is by using a technique known as object pooling.

    Pooly is a professional pooling system that gives you all the tools you need in order to implement and manage the spawning and despawning of a lot of objects at once.

    The system is easy to understand and quick to integrate, allowing you to configure how objects are pooled, how they are spawned and how they get despawned.

    This All-In-One pool management system allows you to create scene-based pools, comes with a multipurpose object despawner and also with an intelligent object spawning system. All the components have clean custom inspectors that will help you configure them in just a few clicks.

    Pooly works in 2D and 3D space, being optimized for all the mobile platforms.

    DOCUMENTATION | FORUM | VIDEOS

    Features
    - Professional Pool Management
    - Independent Scene Pooling
    - Progressive Preloading
    - Multipurpose Despawner
    - Intelligent Spawning System
    - Clean Custom Inspector
    - Works In 2D And 3D
    - Optimized For Mobile
    - Easy to learn. Intuitive design
    - Supports all platforms
    - Comes with full C# source code
    - Dedicated support
    - Tutorials on our YouTube Channel

    As game devs ourselves, we are dedicated to continually improving and expanding our assets, based on everyone's feedback, and also providing top-notch support.
     
    Last edited: Mar 7, 2018
    starfoxy, rakkarage and matteumayo like this.
  2. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Pooly_Screenshot_0-@1280x720.png Pooly_Screenshot_1-@1280x720.png Pooly_Screenshot_2-@1280x720.png
     

    Attached Files:

  3. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
  4. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
  5. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
     
    v_Jay_v likes this.
  6. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
  7. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
     
    v_Jay_v likes this.
  8. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
  9. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    116
    Hi there, is it possible to get access to the last particle I spawned through code? I'd like to set some parameters to the particle effect I'm spawning.

    For example, how could I reference the particle I spawn by doing this:
    Code (CSharp):
    1. Pooly.Spawn(attackObject.GetSFSObject("particles").GetUtfString("hit"), child.transform.position + new Vector3(0, 0.5f, 0), new Vector3(0, 0, 0), gameParticles.transform);
    Thanks
     
  10. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @HolyFireGames,

    Hi there, is it possible to get access to the last particle I spawned through code?
    Sure you can. Pooly.Spawn returns a Transform of the clone you instantiated. Just get a reference to it by doing this:

    Code (CSharp):
    1. Transform lastParticleSpawned = Pooly.Spawn(attackObject.GetSFSObject("particles").GetUtfString("hit"), child.transform.position + new Vector3(0, 0.5f, 0), new Vector3(0, 0, 0), gameParticles.transform);
    Then all you have to do is:

    Code (CSharp):
    1. lastParticleSpawned.GetComponent<ParticleSystem>(); //change the particle system setting here
    Did this help you out?

    Cheers,
    Alex
     
  11. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    116
    Perfect, thanks! Btw, great asset. I've really enjoyed working with it. I'll be sure to get a review on the asset store today for you.
     
  12. Lab618

    Lab618

    Joined:
    Jan 12, 2015
    Posts:
    31
    Hello,

    is it possible to adjust the Random Spawn Interval Times over time? For example if I had a spawner firing missiles at the player and I wanted to increase the difficulty level/amount of missiles over time.

    I use Playmaker so it would be ideal to control it via PM.

    Thanks.
     
  13. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Lab618,

    We designed the Spawners as a pre-defined custom spawning solution. That is why, at the moment, it is not possible to have the Spawner's parameters change automatically over time or via PM.
    What you could do, in described scenario, is the following:
    • Have Spawners with different pre-defined settings made into prefabs and then pooled inside of Pooly.
    • Set the Spawners "Auto Start On" to "On Spawned" - the spawners will automatically start their normal routines when they are spawned themselves
    • Spawn/despawn your Spawners, as needed, using the PlayMaker actions for Pooly
    Does this solution work for you? Let us know.

    Cheers,
    Alex.
     
  14. Lab618

    Lab618

    Joined:
    Jan 12, 2015
    Posts:
    31
    Hi Alex,

    Thanks for getting back to me. That solution could work but I think in my situation creating prefabs and spawning spawners might be overkill. As I can't change the settings I think I'll just set up two or three identical spawners (easy, medium and hard) with different random interval times and just stop and start them as required.

    Thanks again for Pooly, it really has made a big part of my game so much easier to create.
     
  15. Ryoha

    Ryoha

    Joined:
    Mar 5, 2017
    Posts:
    7
    But if possible, please create playmaker action for random Spawn prefab in categories, and Spawn at gameobject.
     
  16. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Ryoha,

    We are currently working on major updates to our assets and will definitely include PlayMaker actions for the Spawner in the next release.

    Cheers,
    Alex.
     
    Ryoha and Lab618 like this.
  17. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    181
    Top notch stuff. I highly recommend pooly for your playmaker project. I actually made a tutorial video on how I setup my spawners, despawners, etc for pooly in playmaker. Its a bit long, everything from zero :)

     
    sharkyro and Lab618 like this.
  18. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @tcmeric,

    Thanks a lot for your endorsement and support!

    Your video shows a solid approach to using Pooly with PlayMaker and the information is very useful and well structured!

    One small observation, for the sake of efficiency: at ~27 minutes - you don't really need to send the spawned clone a reference to itself; you can just use the GetParent action on the clone to get a reference for despawning itself.
    However it is, indeed, a very good example on how to pass around the reference to the spawned GO.:)

    Cheers,
    Alex.
     
    tcmeric likes this.
  19. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    181
    Thanks, that is a good tip. I will work that into my tutorial for version 2 ! ;)
     
  20. Lab618

    Lab618

    Joined:
    Jan 12, 2015
    Posts:
    31
    Hi Alex and everyone else, just a quick post to let you all know my new game for iOS is out. It's called Tower Blast! and is a fun little arcade game with a similar feel to Missile Command. If you get a chance you can download it here: https://goo.gl/uU986A

    It uses Pooly extensively, so much so that I've even given EZ a thank you in the credits. It was used for pooling and spawning the missiles, explosions and power ups. For me the best part of Pooly was the ease of setting up spawners. They're an integral part of my game and I think Pooly along with its Playmaker actions probably saved me days of work.

    If you like Tower Blast! please share it.

    Thank you.
     
    sharkyro and tcmeric like this.
  21. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    That's awesome, @Lab618! Congratz on your new game, will definitely check it out!
     
    Lab618 likes this.
  22. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Hi.

    Interested in this tool. Couple of questions :

    1. How does the pool system know if a object has been spawned or not? I am asking this, because I am currently using PoolBoss, and it thinks an object is already despawned or not spawned if the object is not active in the scene. This is not working for us, because we need to sometimes disable the objects that has been spawned and enable it again without despawning it.

    2. If I have a master pool and then another extension pool in some other scene and then load that extra scene additively, will I be able to access the elements in the extension pool as if I was accessing from the master pool? Also can they (the ones from the extension pool) be destroyed when scene changes?

    Thanks.
     
  23. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @castor76,

    Pooly keeps its own records of spawned/despawned clones, regardless of their state in the scene. You can enable/disable spawned objects as needed, without this counting as a spawn/despawn.

    You always spawn/despawn clones in the same way - it doesn't matter if they were added to the pool by the main pool or by an extension; you don't need to worry about this.
    And, yes, clones added by a pool extension are automatically removed when their extension is unloaded (to free up resources). Simply put: any prefab added by a pool extension is only available as a pooled item as long as the extension that added it is active and enabled.

    Hope this clarifies things, let us know if you have other questions.

    Cheers,
    Alex.
     
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Thanks, I am officially sold!
     
    sharkyro likes this.
  25. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Hi, I am playing with Pooly, but I would like to find out how I can check to see if all preloading has been completed.

    I have a lot of objects preloaded with various different settings on how many initially I spawn and how long I wait for and how many do initialize per frame. So I need to find out if pooly has completed pre-instantiating all of my pool items.
     
  26. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi again @castor76 !

    In the first frame, on Awake(), Pooly goes through the list of prefabs and instantiates their clones - either all at once or on a per-frame basis (depending on your configuration).

    Once Pooly's Awake() finishes, you're good to go; you can start spawning right away! The number of clones you configured to be available on the first frame are created and can be used immediately (and, if you need more, just make the proper configuration for that prefab). You don't need to wait nor check for ALL clones to be available before spawning.

    Edit: The above is also valid for PoolyExtention, except the extension will start adding its own prefabs to the pool at the end of the frame when OnEnable() is called. This is done to ensure the correct setup if Pooly and a pool extension exist in the start scene.

    We didn't really see any use-case where checking if all clones were spawned is needed. If you have a specific scenario where you must have this information, please let us know.

    Cheers,
    Alex.
     
    Last edited: Sep 20, 2017
  27. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Hi @sharkyro

    The reason why I need to know when the instantiating is completed is that I would like to have them running over multiple frames without holding the main thread for the loading screen purposes.

    If I have very large amount of objects then I would like to pre-instantiate it over multiple frames and only comfortable enough to continue once they are all completed. It also has to do with a bit of memory management as well.

    This is important for platforms such as XboxOne and PS4. Where things must be exactly how they must be. I would like to be 100% certain that the pooling initialization is completed before moving on to the next task. ( so that the next task isn't slowed by the pre-instantiating. )

    The same goes for the extension method. We don't want the loading screen to start fade away unless all the objects are pre-instantiated. The minor hickups that you may experience during the pre-instantiation can only happen during loading screen.

    Thanks.
     
    Last edited: Sep 21, 2017
  28. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Humm, after looking at the despawn code, it does seem like it is checking for inactive in scene to determine if it is already despawned or not? I have asked this explicitly if this was the case?

    Can you explain?
     
  29. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Also it would be super to have total number of items spawned within the category next to the name of the category, so that we don't have to open up the category to find out. This is really useful for debugging etc.
     
  30. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @castor76,

    Ok, understood. We're working on introducing this functionality for you. We'll send it to you as a patch, before making it available in a full release.

    It's probably reminiscient from one of the early iterations of the asset, thanks for pointing it out. Quite simply put, that "if" clause should definitely not be there - we're updating this, as well.

    Hmm... On this one, we can't make any promises, as it most likely will not happen.
    We have considered something similar but, ultimately, decided against it. There is not enough room on the category's tab to show accurate and detailed information about everything that is spawned under it. And showing partial/incomplete data is something that we want to avoid.

    Please drop us an email at our support address, so that we have your contact to send you the patch when it is ready. If you have further questions or observations let's also take that discussion to email, so we don't spam any other users following this thread with updates.

    Cheers,
    Alex.
     
    castor76 likes this.
  31. Orexx

    Orexx

    Joined:
    Jun 4, 2017
    Posts:
    18
    Hi @sharkyro

    I had some questions about this asset:
    1. If the bullet released by the game character collides with the enemy, will it be "destroyed" automatically or do I have to create a separate script for this? Simply I somehow used another system of the pool and in it after the collision of objects and their destruction there was a leak in the unity3d.
    2. Despawner is a property that is lost after the "destruction" of the object?
    3. Let's assume in the scene there are several spawners releasing enemies and the player shooting bullets which destroys them. Can I use your asset to control how many enemies will appear in the scene (level) and after the spawn has let out allow 10 enemies it turns off? And if after their destruction I want to finish the level, will I have to create a separate script or is there such an opportunity in the asset itself?

    Thanks, sorry my english )
     
  32. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    Humm , I am wondering if this is bug or not, but we use SVN and every now and then it wants to commit some files from pooly system, I can't remember which files, but they looked like the editor icon files?
     
  33. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Orexx,

    For this exact purpose we also provide a Despawner script that does exactly that. It returns the clone back to the pool. See the Pooly - Spawner and Despawner video to see it in action.

    The Despawner is a component (a script) that returns a pooled gameobject (a clone) back to the pool. The gameobject is never destroyed, it gets disabled and, depending on your usage, also gets reparented back to its source pool.

    When you despawn a clone, you do not destroy it, you disable it and mark it as available to the pooling system.

    Yes, you can do that quite easily. The Spawner has a wide range of options that can be managed from the Inspector or through code that should be useful for most use case scenarios.

    The Spawner does not track what happens to the clones it spawns. All it does is to help you spawn prefabs in a predetermined or random pattern and/or position. You will have to write your own script to track how many enemies have been destroyed and trigger a 'finish level event'.

    Did this help you out?

    Cheers,
    Alex.
     
  34. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @castor76

    Those files never get changed after you installed the asset. They are .png files set to be used inside the editor only (they do not get added to the build, nor can they be used in any of your scenes due to their settings).

    Only if an outside script that modifies the .meta file or a re-import can trigger your SVN to detect a change for those files. Regardless, there should be no issues should that happen, but check if maybe one of your colleagues may have executed a re-import.

    Cheers,
    Alex.
     
  35. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,479
    For some reason the meta files for these icons are changing...
    Gizmos/Pooly/poolySpawnerIcon.png.meta
    Gizmos/Pooly/poolySpawnerLocationIcon.png.meta
     
  36. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Sorry for the delayed response, @castor76.

    These are just used for gizmos for the PoolySpawner, don't worry about them. If I am not mistaking, the meta changes as gizmo settings change; this also happens if different settings are used on different machines.
     
  37. imgumby

    imgumby

    Joined:
    Nov 26, 2015
    Posts:
    122
    Plans to update to Unity 2017 or is already compliant ??
     
  38. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @imgumby

    Pooly is already compliant with Unity 2017. We use it in our own projects developed under 2017 without any problems; if you encounter any difficulties, please let us know.

    Work for version 2.0 of the asset is also in an advanced stage.

    Cheers,
    Alex.
     
    MoribitoMT likes this.
  39. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    298
    Hi,

    Is this asset supported and will have updates in future ? I plan to purchase it.

    Regards.
     
  40. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hello @MoribitoMT

    Yes, of course, our asset is supported and, as stated before, we are working hard on version 2.0.

    Cheers,
    Alex.
     
    MoribitoMT likes this.
  41. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    181
    Does this use stacks or queues?
     
  42. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @giraffe1

    No, Pooly does not use any stack/queue data structures. I am not sure I fully understood your question; if you meant something else, please elaborate :)
     
  43. BryanO

    BryanO

    Joined:
    Jan 8, 2014
    Posts:
    166
    I just bought "Pooly" however Im getting some errors upon load for example :

    Assets/Standard Assets/Effects/ImageEffects/Scripts/BloomOptimized.cs(9,35): error CS0246: The type or namespace name `PostEffectsBase' could not be found. Are you missing `UnityStandardAssets.ImageEffects' using directive?

    Assets/Standard Assets/Effects/ImageEffects/Scripts/BloomOptimized.cs(42,30): error CS0115: `Ez.Pooly.Examples.UnityStandardAssets.ImageEffects.BloomOptimized.CheckResources()' is marked as an override but no suitable method found to override


    Not sure what your pooling solution has to do with image effects...
     
  44. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    175
    hello, is there any chance that version 2 of pooly including some sort of tracking of the number of pooled spawned items? ie: so I can automagically spawn a new AI as one gets killed off?

    Thanks
     
  45. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @BryanO,

    Those image effects files have been copied from Unity's free ImageEffects asset and are used to 'beautify' the example scenes. We also encapsulated those effects files in a separate namespace in order to avoid any issues.

    After reading your post, we did the following tests:
    1. Created a new project, installed the Pooly asset from the AssetStore, opened an example scene. No issues.
    2. Created a new project, installed the ImageEffects asset and then the Pooly asset from the Asset Store, opened an example scene. No issues.
    3. Created a new project, installed the Pooly asset and then the ImageEffects asset from the Asset Store, opened an example scene. No issues.

    May we ask what other assets do you have in your project that may generate the issue you are describing?
    Also, what Unity version are you running on?
     
  46. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @SuperNewbee,

    The feature you are looking for already exists ;), and we can confirm that it will still be available in versions 2.0 and up.

    Now you can get the active clone count (spawned items) in two easy ways:
    1. by using a Transform reference of the prefab you are looking for
    Code (CSharp):
    1. Pooly.GetActiveCloneCount(prefab);
    2. // Returns the number of active (spawned) clones for the given prefab.
    3. // Returns -1 if the prefab was not found in the pool.
    2. by using the prefab name of the prefab you are looking for
    Code (CSharp):
    1. Pooly.GetActiveCloneCount(itemName);
    2. // Returns the number of active (spawned) clones for the given itemName.
    3. // Returns -1 if the itemName was not found in the pool.
    The methods described above are static methods inside Pooly. Thus you can get the active clone count from any script you want.

    Also, there are several other static methods build in Pooly that you might want to check out:
    Code (CSharp):
    1. Pooly.HasActiveClones(prefab);
    2. // Returns true if the given prefab has active (spawned) clones.
    3. // Returns false if the given prefab has no active (spawned) clones or if it was not found in the pool.
    Code (CSharp):
    1. Pooly.HasActiveClones(itemName);
    2. // Returns true if the given itemName has active (spawned) clones.
    3. // Returns false if the given itemName has no active (spawned) clones or if it was not found in the pool.
    Code (CSharp):
    1. Pooly.GetDisabledCloneCount(prefab);
    2. // Returns the number of disabled (despawned) clones available for the given prefab.
    3. // Returns -1 if the prefab was not found in the pool.
    Code (CSharp):
    1. Pooly.GetDisabledCloneCount(itemName);
    2. // Returns the number of disabled (despawned) clones available for the given itemName.
    3. // Returns -1 if the itemName was not found in the pool.
    Code (CSharp):
    1. Pooly.HasDisabledClones(prefab);
    2. // Returns true if the given prefab has disabled (despawned) clones available.
    3. // Returns false if the given prefab has no disabled (despawned) clones available or if it was not found in the pool.
    Code (CSharp):
    1. Pooly.HasDisabledClones(itemName);
    2. // Returns true if the given itemName has disabled (despawned) clones available.
    3. // Returns false if the given itemName has no disabled (despawned) clones available or if it was not found in the pool.
    We did a lot of work on this asset to be as complete as possible. Should you have any other suggestions please let us know and, if possible, we'll implement them.
     
  47. BryanO

    BryanO

    Joined:
    Jan 8, 2014
    Posts:
    166
    I appreciate that - your demos are great and I really like the pooling system. Especially its ability to handle multiple scenes.

    Im using the best selling Lighting Box 2.3 kit to help sort effects Im using Unity 2017.1.1f. It took a little time to sort because of the namespace issue and I didnt expect your package to have visual effect scripts. No Biggy.

    In an unrelated issue - is there some way to use a script wizard to sort instantiate and destroy calls in existing projects?
    I have bullets and impacts and scorch effects and explosions and blood to sort and each has its associated "instantiate and destroy" and idiosyncratic syntax. - So I wondered if you know of something more robust than "find replace" to insert "spawn and despawn" with its correct syntax for your package at each call?

    And finally - do I just drop the timed despawner on a prefab slated to spawn to make it disappear after a little while? Is there much cpu overhead in the timer? also is there a way to trigger a "death effect" prior to timed despawning?
     
    Last edited: Nov 2, 2017
  48. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Briano,

    We're afraid there is not way to create such a wizard as it would need to read your code, identify the lines that contain Instantiate/Destroy calls and then rewrite the entire class (file). This type of wizard can be theoretically created, but it would be quite error prone and could potentially mess up good code. The safe way to replace your code would be usinfg the find/replace functionality provided by your IDE.

    Yes, that is exactly how it works. You add the Pooly Despawner component and set its settings. You can also trigger an UnityEvent prior to despawning the clone.

    Nope. It all happens in a Coroutine (in an independent thread), not in the Update() method. Thus it's as efficient as it can be.

    Yes. You can spawn a different prefab (a clone of that prefab - maybe an explosion/effect/sound/etc...) by using the provided UnityEvent. We also did this in our example scenes, where we spawn a projectile and when it hits a wall (or explodes) we despawn the projectile clone and spawn an explosion prefab instead (the explosion prefab also has a despawner).
    You can mix and match all the components to create all sorts of setups (split shots, grenades, fireworks, etc...) and, by using a pooling solution, it will all work very fast and efficient.
    We tried to make this pooling asset as easy to use and efficient as possible, while covering as many use cases as we could think of.
     
  49. johny256

    johny256

    Joined:
    Mar 3, 2015
    Posts:
    186
    Add integration Ultimate Survivar
     
  50. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @johny256,

    Can you please elaborate at what exactly are you looking for in terms of integrating Pooly with the Ultimate Survival asset?