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
    V 1.1.8 Changelog:
    • Added ability to delay enable of NavMeshAgent by X frames after spawn, to fix a NavMeshAgent bug.
    • Added a check inside PoolBoss.Spawn to log if the pool hasn't been created, for troubleshooting.
    • Fixed unreadable Inspector in Unity 2019.3.
     
  2. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    107
    Does this work with Photon PUN yet ?
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, might never work with any multiplayer component. It's a tough problem.
     
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,683
    Is it possible ... does it make sense ... for Pool Boss to be hooked up with the addressables package?

    I was thinking the "auto-add" feature Pool Boss has is great, and then I was thinking, what if use of addressables enabled Pool Boss to automatically remove unused items from the main list?
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I actually plan on doing Addressable support for Pool Boss in both the standalone and Core Gamekit next month.

    However, it might not work the way you think. Basically all the pooled clones of an Addressable won't be ever released from memory until the entire Pool Boss game object is destroyed. Which may never happen for some games.

    It will give you the ability to work with Addressables, and that's about it.

    Also, you will need to load whatever externally hosted Asset Bundles contain the Addressables in your pool(s) beforehand, or you risk waiting seconds for those to download before Pool Boss can do anything with it.
     
  6. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,683
    I was thinking there would probably be some hitches. I was thinking that with items in the pool, those assets would always be in use and never drop out.

    But I thought it was worth asking about. :)
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah I think that's true. Although when the pool boss gets destroyed they should be released.

    I do intend to make a "mini pool boss" like Dynamic Sound Group Creators in Master Audio, and then you could add groups of pooled items temporarily to use, then destroy it to release the addressables within.
     
    hopeful likes this.
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.1.9 changelog: Addressables support is here!

    • Added support for experimental Fast Play Mode in Unity 2019.3 - it works by default it you turn on Fast Play Mode on the Unity menu as shown on this page: https://blogs.unity3d.com/2019/11/05/enter-play-mode-faster-in-unity-2019-3/
    • Added Welcome Window, to enabled Addressable support if you have the package installed.
    • Added Addressable support for Pool Items! Enable it by checking the Addressable checkbox on the new Welcome Window!
    • There's no longer a cap of 100 on the Initialize Time (Frames) field in Pool Boss. It can be as high as the number of prefabs.
     
  9. OccularMalice

    OccularMalice

    Joined:
    Sep 8, 2014
    Posts:
    169
    Hey @jerotas

    Just got PoolBoss and it's great. One bug I think I found is that I've dragged the prefab for PoolBoss into my scene then, as instructed in the docs, dragged it into my own folder. I created a new prefab (not a variant). When I select the prefab in the scene it's fine, but when I select the prefab in my project hierarchy the Unity hourglass goes nuts. Doesn't seem to do anything (other than spins) but doesn't affect the game at all and once I click off my prefab onto anything else it stops. I'm on Unity 2019.3.14f1.

    Thoughts?
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I actually saw this today. I think it may be a Unity bug. I'll try and look into this tomorrow or early next week.

    Will report back.
     
    OccularMalice likes this.
  11. OccularMalice

    OccularMalice

    Joined:
    Sep 8, 2014
    Posts:
    169
    Great thanks! Sorry for posting here but didn't want to create yet-another-login to post this on your forum.
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Here is fine. You can also email us at support@darktonic.com in the future. We check that every day.
     
    OccularMalice likes this.
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Are you sure you're using the standalone Pool Boss plugin? I found this problem in Core GameKit's Pool Boss but not in the standalone. I can't make it happen.

    Can you make it happen in the provided Example Scene?
    If not, can you send me an example project that reproduces the error?
     
  14. OccularMalice

    OccularMalice

    Joined:
    Sep 8, 2014
    Posts:
    169
    I'll try the example scene in a clean project and if not try to reproduce it. Thanks.
     
    dark_tonic likes this.
  15. OccularMalice

    OccularMalice

    Joined:
    Sep 8, 2014
    Posts:
    169
    Just emailed a sample scene that reproduces the issue (at least for me). Just a blank scene with PoolBoss imported. Instructions are in email.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.2.0 changelog - Pool Mini-Boss is here!
    • Fixed spinning Inspector when selected in Project View in Unity 2019.3
    • Changed max limit on Init Time (frames) in Pool Boss to be 1000. No longer capped at the number of pool items you have.
    • Added "Pool Mini-Boss" prefab, which is like a mini Pool Boss. It is used to create temporary pool items in Pool Boss. They are created when the game object is enabled, and removed when it is disabled. It supports Addressables and will automatically release Addressable memory when it's disabled or destroyed.
    • Added method you can call on Pool Boss to destroy all items and release Addressable memory prior to letting the Game Object get destroyed when changing Scenes: PoolBoss.DestroyAllItemsAndReleaseMemory
    • Fixed constantly saving prefab mode inspector for Pool Boss in Unity 2019.3
    • Fixed broken Addressable spawn.
     
    hopeful likes this.
  17. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @jerotas I've noticed with Addressables that PoolBoss.cs is setting _isReady = true even though in the Addressables Event Viewer I'm still seeing events occur for several seconds afterwards (AsyncOperationCreate, etc).

    Is there a way to know when PoolBoss is truly finished loading with Addressables? In my case it's important so that the user is not allowed to exit the game and return to the Main Menu until I can guarantee PoolBoss is finished. Otherwise some serious errors get thrown as it destroys PoolBoss while it was still in the middle of Loading / Instantiating objects.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I took a look at the code and it looks correct. It doesn't increment _itemsInited until after the Addressable is loaded, and _isReady isn't set to true until all items are loaded and cloned. So I can't reproduce this at all on my end.

    Let me see the error you're seeing because on the newest Addressable package they broke it when you load a second time and I'm looking into that soon. What version of the Addressable package are you on and which Unity?

    The thread about that is here if you want to read it to see if it's what you're running into.
    https://forum.unity.com/threads/1-15-1-assetreference-not-allow-loadassetasync-twice.959910/
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    This issue was fixed long ago, forgot to update the thread.
     
  20. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @jerotas Here is the error being thrown. Again, only happens if I tell PoolBoss to destroy / cleanup while it appears it's still loading / activating game objects.

    Here's a screenshot showing the Addressable Event Viewer right after I've exited to the main menu. You can see it's got both Destroying and Complete events happening at the same time.....

    upload_2020-10-15_17-59-9.png

    Obviously that's because I've told it to destroy while it's still loading stuff, but that goes back to my original issue of _isReady seemingly being set true before it's actually finished.

    I think you should be able to easily reproduce if you simply create a prefab, set it up as Addressable and have PoolBoss spawn like 1200 instances or something. Then Log a message when _isReady is set to true while you have the Addressables Event Viewer open and you should see it's still processing stuff.
     
    Last edited: Oct 16, 2020
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    To be clear, you waited until _isReady was true before you started destroying stuff right?

    I also still need to know what version of Unity and Addressable package you're using
     
    Last edited: Oct 16, 2020
  22. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Ah flip. Soooo it turns out that my yield statement that was checking _isReady was returning true when it shouldn't have been. My bad, I'm sorry for wasting your time :(

    I'm using something called Better Coroutines and this was returning as True even when _poolBossReady was false....

    Code (CSharp):
    1. yield return Timing.WaitUntilTrue(() => _poolBossReady);
     
    hopeful likes this.
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No offense but that doesn't sound like a.....better anything. I didn't try reproducing it yet so no sweat.
     
  24. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @jerotas Well, now I take it back again. It does seem to be acting as I originally described. When you have a chance please do a quick reproduction test on your end :/
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I believe we resolved this? Just saw this message very late.
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 1.2.1 changelog:
    • Fixed bug: SpawnWithFollow method in Pool Boss didn't work properly.
    • Fixed bug: False warning was logged when you use different Pool Bosses in different Scenes.
    • Fixed bug: Addressables package broke its usage so code has been modified to work with the latest version.
    • Removed Unity 5 support.
     
  27. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Hello!

    Is there a way to spawn a single random object from a specific catigory in a pool made with PoolBoss?

    Right now, I'm am thinking of selecting a random child from the pool object in the scene, and spawning that. But I'm wondering if there is a better way to do this.

    I am using PlayMaker by the way. Are the objects in the pool indexed kind of like arrays are so I can just pick a random one like that?

    For context: Each object in the pool is a question with multiple choices. I only want one to show up at a time, but I want spawn a random prefab in the pool. They'll all be at the same location.

    Let me know if you need anymore details. Thanks for the help in advance!
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You get items out of the pool by name, not index.

    The feature you are looking for is in Core GameKit but not the basic Pool Boss. It's called Prefab Pools and you can assign a weight to each item in the pool for random probability.

    You can always upgrade to Core GameKit, you only pay the difference since you already own Pool Boss.
     
  29. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Thanks! If I use this, will I have to reset PoolBoss?
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes you will. It's a separate product.
     
  31. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @jerotas Can you give some insight on the correct way to cleanup a scene that contains a mini poolboss that's using primarily Addressables?

    I see that there is a `PoolBoss.DestroyAllItemsAndReleaseMemory();` method, do I want to call this prior to unloading the scene in which the PoolBoss manager object exists? Or will the proper cleanup happen automagically when the scene is unloaded?
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Documentation says it should happen automatically, except for Addressables. If you are using Resource files, or plain old prefabs you shouldn't need to call it. I didn't remember, so I looked at the code comments to make sure.

    -B
     
    Last edited: Apr 21, 2021
  33. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Okay, one issue I've noticed that you might want to look at for a future update is that PoolBoss fails to find / unload objects that have been loaded via Addressables and have a GameObject prefab name that differs from the Addressable name.

    For example I had the Addressable: "ShotgunBlastAnimation" and the gameobject prefab name was "shotgunBlastAnimation". When calling "DestroyAllItemsAndReleaseMemory" it fails to find it and throws error:

    I'm able to rename my prefab name to match the Addressable name, but this seems like PoolBoss should keep reference to these objects via Addressable naming when they are marked as Addressable.
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm looking at the code, and that shouldn't happen. The dictionary key is case-insensitive. It uses the name of the prefab. Anyway I can't reproduce it.

    You'll need to send me an example Scene if you need it fixed.

    -Brian
     
  35. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    lol okay.
    Gotta love how passive aggressive you guys are towards supporting your customers that run into issues. I've hit 2 major bugs with PoolBoss / Addressables up to this point and have been treated as a hassle when asking for help.

    I get it, but I certainly will not be using DarkTonic products moving forward on future projects.
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sorry if you see something is passive aggressive about my response. I went and looked at the code, very promptly, and didn't see the issue as you described. The name of the GameObject in the Addressable is what's stored.

    If "Documentation says" triggered your response, please know that I'm not saying "read the manual", but letting you know that I actually went and checked what the code comments say myself so that I'm sure I'm right before sending you off on a possible wild goose chase relying on my memory.

    A couple years ago, we did change our bug reporting policy, so that we request an example be sent to us. The reason why is that previously a lot of time was wasted on both ours and the customers side when trying to reproduce issues in a vacuum. A lot of the time I never even could. So in the interest of getting you fixed correctly the first time, that is how we handle things now.

    Admittedly, I'm not very knowledgable about Addressables. Namely, I'm not even sure how your Addressable could have a different name than the prefab...I drag the prefab into the Addressables window and that's it.

    I appreciate that it's a hassle for you to get that together, but you should appreciate that I am unable to help you if I can't reproduce the issue on my end, except for the simplest of issues.

    Looking back, it looks like you are the user that asked us about supporting Addressables, which is cool.

    Best of luck,
    -Brian
     
    Last edited: Apr 22, 2021
    SuperMiro likes this.
  37. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, so, after trying to find out for very long time just why pool boss is spawning the same prefab multiple times, I have found that when you disable the game object of the pooled item, and enable it again, it adds to the SpawnedClones making the system think that it has spawned again.

    While I can understand why this is implemented such way, this isn't necessary true for all use cases. Because if I use it for way some UI elements and wants to hide them and wish to toggle them around then we don't want to recreate/rebuild the UI. I want complete control on when I want the poolables to be spawned and despawned.

    This can also be seen at the PoolBoss UI where you toggle the pooled game object active on off then it keeps adding the the number of objects that are spawned. So when you ask to spawn some object, it returns the one that is already been spawned.

    I think there should be an option to totally disable this. (And) Or have option per item so that they have option to not considered to be "_potentialInSceneObjects" to be added.
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks, I believe that's happening from the OnEnable and OnDisable methods on PoolableInfo. Unfortunately that can't be removed because it would break "start in scene" objects and it would also not unregister them when they are destroyed (and not despawned) when the Scene changes and destroys everything.
     
  39. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,683
    Rather than turning the object on and off, can you turn the key component on and off? Or have a top level object and toggle a child? Though maybe I'm not understanding, in which case ... nevermind! ;)
     
  40. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Which is why I think they should be optional. We should be able to selectively choose if we would like that in scene object functionality. Both by global option and per item option, just like many others we have already.

    Also maybe consider using ondestroy for dealing with scene unload and destroy spawned objects.

    Onenable and ondisable could mean so many things.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Unfortunately, OnDestroy is pretty much unusable for scripts talking to scripts. It inevitably results being spammed with "Object being destroyed" state errors if for example your Pool Boss is also being destroyed, and there's no way to know that in advance.

    What you are describing can be done without much effort, but I need to understand what the issue is to you, as I currently do not. I don't think the count of anything is off at any time. Please explain more fully. I would need to reproduce the actual bug on my machine as I may think of a different fix. It sounds like you're saying that the "spawned" Pool Boss item that you've disabled in the UI is respawned somewhere else when you need a new one, and you want it to now be able to be chosen for spawning until actually despawns. Is that correct? If so, I can try and reproduce that in my example scene.

    Thanks!
    -Brian
     
    Last edited: May 21, 2021
  42. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Something like that. The source of the problem is that when Spawned object is disabled and enabled for whatever reason, the system thinks that it is _potentialInSceneObjects, so adding to that. Which causes the internal SpawnedClones list to ever increase. Which is not good, because then it becomes totally out of sync with what's actually spawned and not spawned.

    Good example is something like this.

    If I make say UI element of inventory item and spawn them to the scrollview or gridlayout and then hides the inventory by deactivating the parent ui control, when you want to show the inventory again, you may just want to reactivate the parent control, instead of rebuilding entire inventory system over and over again. When you do this, the poolboss thinks that the previously spawned items are spawned again adding to the internal list.

    Now, I am not sure exactly how internally this affects my normal Spawn call, but when this out of sync happens, I ask for spawning an element, but it was already in the scene, cross referencing each other.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks.

    I have made the change and added a "Register In-Scene Items" checkbox at the top level and per item. If you uncheck it, those methods for Enable and Disable will not be called. You want to email me for the updated plugin to test it? support@darktonic.com and send your Asset Store invoice PDF file please.

    -B
     
  44. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Excellent. Sent!
     
    jerotas likes this.
  45. aidinz

    aidinz

    Joined:
    Apr 17, 2016
    Posts:
    63
    Hi,

    Apparently PoolBoss doesn't detect variant as separate Prefab. I have four prefabs which three of them are variants of the other one. I dragged them all into PoolBoss but the log says "You have more than one instance of 'Enemy_Black' in Pool Boss. Skipping the second instance.".

    Any workarounds?

    Thanks.
     
  46. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    if you tak a look at the prefabs, they all have components with pool name in it. You have to change them. Poolboss uses the name in the component to identify different prefabs. Not sure why it is made this way... it should just be game object name in my opinion. Unless there is some really good reason for this...
     
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I believe we added this script to eliminate Garbage Collection and help with "already in Scene object that need to be pooled". It also allows code to change the GameObject name without breaking Pool Boss, which some customers were doing. But in any event, it should now help with Variants.

    #1, if you can actually change the Game Object Name of the variants (I don't use them so I don't know), then do that prior to dragging them into Pool Boss.
    #2, if that's not possible or you don't want to do that, there's a script called PoolableInfo (as Castor was talking about), that has a field called Pool Item Name. It is automatically populated with the Game Object name, but you can change it to whatever.

    For #2, only one Game Object in Pool Boss can have the same Pool Item Name, because it's the key in the dictionary and makes thing work without a lot of extra steps (unlike say PoolManager plugin).

    Let me know if either of those work for you.
    -Brian
     
    Last edited: Oct 4, 2021
  48. aidinz

    aidinz

    Joined:
    Apr 17, 2016
    Posts:
    63
    Thanks for the quick reply guys! Much appreciated as I'm under a tight deadline.

    Renaming the prefabs worked. I think it didn't register first because when you make a prefab variant, it puts the "variant" string after a space after the master prefab's name. I suspect PoolBoss not happy with that space.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem.
     
  50. jerotas

    jerotas

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

    • Fixed bug when spawning on an UI element from Playmaker.
    • Fixed bug where Pool Boss would never finish Initializing if a pool item Preload Qty was set to 0.
    • Added new Playmaker Custom Actions: Create New Pool Item, Initialize, Is Ready, Destroy Pool Item, and Item Is Spawned.
    • Added global and per-item option for "Register In-Scene Items" (defaults to checked), that you can uncheck if you wish to disable spawned objects and not have them be used for spawning until they are despawned.