Search Unity

[Released] Pool Boss - super easy pooling solution.

Discussion in 'Assets and Asset Store' started by jerotas, Oct 20, 2014.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The CGK release missed the last thing I did for Pool Boss also, so I'm going to release an update to both, hopefully this weekend.
     
  2. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Great news, thanks!
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.3 changelog:
    • Cleaned up Garbage Collection.
    • Bug fix: PoolBoss.NextPoolItemToSpawn returned null even when Allow Instantiate More is checked.
    • Added "Initialize Time (Frames)" field. Defaults to 1. Now you can configure how many frames it takes to create all pools. You can set it between 1 and the number of different prefabs you have in Pool Boss.
     
  4. Deleted User

    Deleted User

    Guest

    When I spawn an image or text in a canvas it's scaled by 1.619433

    Is this a bug?
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    There is no scaling code at all in Pool Boss. This probably happens because you have a scale other than 1 on your parent (canvas) game object or something like that, so Unity is trying to fix it back to the scale in your prefab by reversing that.
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Attention: Dropbox is dropping support for public links, so we have moved everything (API websites, documentation, downloads) to our new domain www.dtdevtools.com. All our plugins have a new version published with updated links. Please download the latest so as to avoid any dead links. This is important for Master Audio especially, since they help links in the Inspector will be pointing to Dropbox until you update.

    Thank you for your support!
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, so after countless days of trying to figure out what the problem is for my game using the pool boss, I found that :

    if the gameobject is disabled, then I think pool boss thinks it is already despawned. So calling despawn all and such command does apply to them.

    While I can understand the mechanics behind it, I am not 100% sure if I want to agree to the method. I think there will be some cases where we do want to disable the gameobject without despawning it and enable it again for some game play sake.

    I think the pool system would be much better if it is designed to track if the object is spawned or not by some other flag, or other method than relying it on being active in the scene.
     
    Quatum1000 likes this.
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That is correct, if inactive it's already considered despawned. It's an easy way to check that 99.9% of everyone has no problem with (we have over 6,000 users and this is only the 2nd request to change this).

    I do not want to add a script or get InstanceId in a HashTable to figure out if something is spawned as that will hurt performance. Of course the entire reason to use pooling is to gain performance. Don't like the idea of slowing it down by adding something that 0.01% of users might want.

    All the pooling systems do it this way, that I am aware of. I've worked around it before by just disabling certain scripts and enabling them later.

    Could you give me a couple instances of where it's valid to disable and re-enable an object but you later might want to despawn and spawn it? I only do one or the other.
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have some props spawning in the level and they gets culled out for optimization reason. I can ofcourse try and turn off scripts, renderers etc instead, but it is much easier to just turn off the game object. There is ofcourse be some overhead of keeping the reference to those, or getting components from it if not cached. Also if the structures of the props are different then I have to account for that too.

    Also for instance if your character has a weapon that only shows / activate collision when you use them, you need to make it activate and then deactivate it. It's just that fiddly to keep track of this myself, when all I want is to call despawnall to clean them up.

    I used Pool system from https://www.assetstore.unity3d.com/en/#!/content/1010 version 3 before , and it didn't have this issue. Also checking out the Pooly asset and it seems like it doesn't have this issue neither.

    I can understand why it is like this for poolboss, for performance reason, yes. It's ok, if the system isn't going to change. I just needed to know for sure so that I can adjust to it, or use other asset.

    I am not sure if this is a good idea or not, but perhaps when you spawn an object if they are not under the spawn system's parent gameobject you could consider them to be spawned. For API that spawns under the spawn system, you could parent it under some special gameobject to "tag" them as a spawned ones. This ofcourse does have some overhead of reparenting, but this happens sometime anyway. Just my thought. It's pitty that we can't add custom property to the gameobject itself. (not components!)

    Thanks.
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I used Pool Manager before, probably 4 years ago, and the IsSpawned check was exactly the same as ours. He might have changed it at some point. A few weird "extra steps" in using Pool Manager is why I built ours, to eliminate all that and make pooling "smarter".

    I'm not going to require that people keep their spawns at any certain location or with a certain parent in the Hierarchy. Some people like it all under Pool Boss, some people like it all outside, so that solution wouldn't work.

    I could consider adding an option that says "Can Despawn Disabled" and defaults to off. That way the performance penalty wouldn't hurt people who don't need that.

    I'll put it on the roadmap, thanks.
     
  11. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    I have to create a pool of Texture2D. How would I please achieve this?
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You pool entire Game Objects with this, not just a component. You can make Game Objects that have Texture2D on them and use script to extract just that component if it helps you, after spawning.
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Happy Cyber Monday! Master Audio is on sale for half off, and the rest of our plugins are 30% off, for a limited time! Grab 'em while they're cheap if you don't already have them. Links in my signature.
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.4 is released! Changelog:

    • PoolBoss check for "IsActive" slightly different now to fix another rare bug. Should not break anything though.
    • PoolBoss has new checkbox for "Can Disabled Obj. Despawn" (defaults to false). If you need to be able to despawn a game object you have disabled, you must check that box. It is worse on performance because it doesn't only check "is the object enabled" so only use it if you must have the ability.
    • Fixed: there is no garbage collection during Despawn now.
    • Fixed: garbage collection issue in Pool Boss Spawn method.
    • Change: Removed from API all "string prefabName" parameters since now the grabbing of prefab name is not doing any garbage collection.
    • Added "keepParent" parameter to PoolBoss.Despawn, defaults to false. If you specify true, the Game Object you are despawning will stay where it is in the Hierarchy, disabled. Useful for things that screw up when activated under Pool Boss (UI components come to mind). To respawn one of that Pool item in the same position, use PoolBoss.Spawn and pass in the intended parentTransform.
    • If you want Pool Boss to have better performance and register in-Scene game objects so that they can be despawned with "DespawnAllOfPrefab" and show in the spawned count, attach PoolableInfo script to your in-Scene objects.
    • Added extension methods to PoolBoss: OnLayer and WithScale. You can chain these with a Spawn call, like this: var spawned = PoolBoss.SpawnOutsidePool(ProjectilePrefab.transform, this.trans.position, Quaternion.identity).OnLayer(LayerMask.NameToLayer("IgnoreRaycasts")).WithScale(new Vector3(4,4,4));
    • Changed the default: Now NavMeshAgent components on Pool Items are not automatically enabled on spawn. There is a new setting for Pool Items with NavMeshAgent to make it work as before.
    • Added ORK Framework integration as an optional package.
    • Added Makinom Framework integration as an optional package.
     
  15. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    In what version of Unity is this true? I'm still using 2017.2.1p2 and getting the name still makes garbage.
    Since they removed DX9 support from the newer version, I'm not planning to update.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    All. Not version dependent.

    If you're getting it from an in-Scene object (pre-spawned), you will need to add the PoolableInfo script to it for the first despawn call.

    Prefabs configured in Pool Boss will automatically have that PoolableInfo script added to the prefab. Do a quick check that that script exists on the prefab, because it's how we get around the G.C.
     
    Last edited: Feb 16, 2018
  17. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    Oh I see what you mean now. Performance wise, can you use a static Dictionary with all the PoolableInfos with the Transform used as a key, so instead of using GetComponent, you can get the PoolableInfo from the Dictionary with the Transform. Just an idea, something I use a lot to get away from GetComponent.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Interesting. I read that GetComponent only actually causes G.C. in the editor though.
     
  19. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi,

    I have a technical question. If I load an additional scene, and there are several empty gameobject place holders where to spawn game objects from the pool. Searching all new loaded Go's from the scene by tag seems to be not a efficient way.

    * Any solution to speed up this?
    * Do you have any speed statistics how many gameobject can be spawn by position, rotation and enable in 1 or 2 ms?
    * Would it possible to spawn object by co-routine in PoolBoss as well ?
    * I'm not familiar with the new ESC but you think spawning object by the Job system and optimized data arrays could be faster and is there a chance to include this into PoolBoss if possible?

    Perhaps in this case I described above, it would be clever to have a static job array save with the scene and let PoolBoss place object to the array info?

    Thank you!
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Never find all game object by tag or name. Terrible on performance potentially.

    Have a script in the new scene that holds an array of all the game objects or scripts. Then loop through them and do stuff. You could limit it to X per frame if you like. Generally avoid CoRoutines as well.

    How many can spawn in how much time is entirely can vary tremendously depending on how many scripts the things you are spawning have and the complexity of the scripts. So there's no predicting how many can spawn in a second.

    I haven't looked into the job stuff at all. Got a link for me to read?
     
  21. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    It's not that easy to find.
    I tthink the job system with the internal data arrays will be a interesting start.
    The ECS seems not that important because it groups components and gameobjects.

    Unity start


    Another tutorials.

     
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks, that looks cool. Will see if this is useful for our purposes or not.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I've watched the videos. I don't think that this will help with Scene load time at all. It will just be running on a background thread and take just as long to finish (the initial filling of the Pool). I don't think that using a CoRoutine for spawning things is needed either. We already have time-slicing on spawning waves by using our spawners, but without the Garbage collection of CoRoutines.

    The best thing to help with Scene load time is probably the "mini-Pool Boss" game object idea that we may build and you can put small amounts of per-Scene prefabs you want to pool instead of everything in a single persistent Pool Boss. It's on the Core GameKit roadmap so if it gets built it will go into Pool Boss standalone as well.
     
  24. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    I think the important thing is positioning go's out of the pool. Accessing an Array to determine the position is fast. But moving pool.gameobject.transform.position, rotation out of the pool is very slow.
    1) Because the transform of each gameobject in the pool is spread over whole memory and.
    2) Accessing each gameobject.transform.position use internally gameobject.GetComponent<Transform>().position.
    So now you now why its slow.

    Moving ~100.000 gameobjects require ~7-8 seconds basically. The job and simple ESC ComponentSystem use the optimized data array and moves & rotates the same gameobjects in about in 7ms. And the nice thing is, through that speed you're able to instantiate objects with same extraordinary speed. Instantiating 10.000 gameobjects in about ~0.01ms is easy possible.

    For sure it's hard move forward with new concepts. And sometimes it makes no sens for asset developers to spend much time & work into new concepts because of "rolling off assets" that doesn't have revenue share line at the beginning.

    Thanks for your time.
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Do you have a need to move 100k game objects? That's a pretty ridiculously high number. You can already tell it what position to spawn at in the Spawn calls.

    I don't think you can instantiate a huge number of game objects in basically zero time. That's why pooling is needed, but you have to wait for the object pool to build up.

    I'm not sure what you mean about "revenue share".
     
  26. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Watch this video from Joachim Ante explaining this.


    To help you get started, we provided a repository of examples for learning how to to write systems at scale.
    Sample projects for the Entity Component System and C# Job System
    Further sample projects on the C# Job System can be found here

    But is not my job to make you believe in this.
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Wow that's over an hour long. Is there a part you can point me to?
    It would only make sense with a ridiculously powerful device with lots of cores to be able to do that.
     
  28. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    An 8 year old intel 2500k with 4 cores and 16 threads is able to do for currently for about 40$. Can't see any ridiculously powefull devices are required here. Anyway good luck for you and your asset the future.
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I can't see how it would be about a million times more efficient than the Unity engine main thread....

    Thanks for the link.
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I posted a thread in the Job System forum. Apparently you can't Instantiate a game object in the background threads. So this idea is a no go. Thanks for the idea though.
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.5 is released, changelog:

    • Fixed warning on Unity 2018.2.
    • Now compatible with Bolt Visual Scripting.
     
  32. seeting83

    seeting83

    Joined:
    Nov 24, 2018
    Posts:
    1
    I've viewed the recordings. I don't believe that this will help with Scene stack time by any means. It will simply be running on a foundation string and accept similarly as long to complete (the underlying filling of the Pool). I don't imagine that utilizing a CoRoutine for bringing forth things is required either. We as of now have time-cutting on bringing forth waves by utilizing our spawners, yet without the Garbage gathering of CoRoutines.
    Without a doubt it's hard push ahead with new ideas. Furthermore, at times it makes no sens for resource engineers to invest much energy and work into new ideas in view of "moving off resources" that doesn't have income share line toward the start.

    summer waves pool cover 10
     
    Last edited: Dec 15, 2018
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm not sure what you're referring to. Are you talking about the Job System, and saying that it wouldn't really help? I really am not sure what you're trying to say - as far I can tell this is your first post here so I don't know what you're replying to.
     
  34. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Hey, Is there a way to totally reset my pooled objects back to how they were when they're first spawned? Thanks
     
    Last edited: Nov 25, 2018
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That would be great but no. It's not possible for that code to be written in a generic way. You'll need to add code to the Onspawned method to reset everything you need reset.
     
  36. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Ok thanks.
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No prob.
     
  38. SuperMiro

    SuperMiro

    Joined:
    Nov 23, 2018
    Posts:
    53
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I didn't get notification of this message, so I apologize for the late reply.

    A stable asset like Pool Boss doesn't need updates unless a version of Unity deprecates something, and that hasn't happened for some time, so we haven't submitted different versions of Pool Boss with different Unity versions. But it does work in all Unity versions 5.2+.

    Submitting an update today in fact with a couple bug fixes.
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.6 changelog:
    • Fixed Garbage Collection bug.
    • Fixed Unity 2018.3 Project View detection.
    • Fixed Unity 2019.1 UI issues.
    • Added methods: CategoryActiveItems, CategoryItemsDespawnedList to get a list of what's spawned and available.
    • Now minimum Unity version is 5.2.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.7 changelog:
    • Fixed bug in Inspector during Play Mode for Unity 2019.
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit is on sale for only $20! The upgrade pricing from Pool Boss is only $10 during the sale! Great time to pick it up and get the extra functionality of CGK. Link is in my signature.
     
  43. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Hello. I'm using Unity 2018.3 and PlayMaker 1.9 p4. Does Pool Boss work with these versions? Just want to make sure before purchasing.
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes it works with all the versions of unity and playmaker. We do not announce support unless it's universally true. Beta versions of unity we do not officially support but when there are breaking changes and someone informs me I fix them as well.
     
  45. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Ah thanks! I got it and it is working pretty well! One thing I'm having a bit of an issue understanding is this;

    I would like spawned objects to despawn when the object collides with a trigger. I'm using PlayMaker, so in the prefab, I have it set so that upon entering the defined trigger, that particular object despawns. I'm using the Despawn action for this with the game object parameter set to Use Owner. However, when the trigger collides with the object, all of the currently spawned objects despawn.

    Why does this happen? Thanks.
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No idea, that sounds weird. What Pool Boss API are you calling when you want it to despawn? It could be a bug in that Custom Action.
     
  47. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    I looked in the PoolBoss despawn's action code and it says "using Poolboss;"

    The despawn code is just

    Code (CSharp):
    1. // despawn!
    2.         PoolBoss.Despawn(this.trans);
    3.        
    4.         Finish();
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    So yeah, that will only despawn the Game Object that it is on, including any sub-game objects. I'm unable to help beyond that.

    You can turn on the Logging checkbox in Pool Boss to see if more than one thing is triggering Despawn. Check the Console window.
     
  49. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Here's a video kind of explaining the issue.

    EDIT: I think it may hve something to do with the trigger because if I tell it to despawn after doing some other command like waiting, it works fine.
     
    Last edited: Sep 26, 2019
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Cool. Cheers!