Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

PoolManager [By Path-o-logical-Games]

Discussion in 'Assets and Asset Store' started by Rafes, Sep 13, 2011.

  1. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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.
     
    Last edited: Apr 29, 2013
  2. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    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?
     
  3. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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.
     
  4. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    Thanks for your answers :) 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 :D
     
  5. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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!
     
  6. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    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
     
    Last edited: Sep 14, 2011
  7. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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....
    PHP:
    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.
     
    Last edited: Sep 14, 2011
  8. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @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 :)

    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 ;-)
     
    Last edited: Sep 14, 2011
  9. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Last edited: Sep 14, 2011
  10. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    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 ;-)


    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 :)
     
    Last edited: Sep 14, 2011
  11. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Released Version 2.1.1. Minor fix. See notes in OP.
     
    Last edited: Sep 19, 2011
  12. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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?
     
  13. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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!)
     
  14. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    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.
     
    Last edited: Sep 26, 2011
  15. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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.
     
  16. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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,
     
  17. patch24

    patch24

    Joined:
    Mar 29, 2009
    Posts:
    120
    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
     
  18. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    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.
     
    Last edited: Oct 15, 2011
  19. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    (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.
     
  20. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
  21. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    This is excellent Rafes! I was thinking about building something like that for Freakow's own games but with such an excellent, value-priced product we might not need to ;) Congratz!

    PS.: Can you pre-load from "prototypes" (ie. actually spawned, disabled game objects) or only prefabs? The reason is simple, some references can't be kept with prefabs.
     
    Last edited: Oct 17, 2011
  22. poppichicken

    poppichicken

    Joined:
    Mar 20, 2009
    Posts:
    34
    Excellent! I'll have a look at the update later tonight!

    Rafes - thanks for your efforts on this project - much appreciated.

    Also, thanks for your brilliant support recently with the little problem I had with UnityConstraints.
    Your products and support are first-class.
     
    Last edited: Oct 17, 2011
  23. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Thank you very much for the kind words!

    PoolManager version 2.5 has been accepted by the asset store and should be available there as well now..
     
  24. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    A few things come to mind.

    First, in case you don't know, you CAN pool instances which are in a scene before you start the game. Check out the pre-runtime pool item docs for details: http://docs.poolmanager.path-o-logical.com/home/4-pooling-pre-runtime

    If you are talking about spawning an instance and then using that to pool clones of this clone, then I believe so. In a way this is more about Unity than PoolManager. I don't think I added anything that would block using an instance to create a pool. Unity allows this and the implimentation should be flexible enough to just accept this scenerio. What I would expect to happen is a new "PrefabPool" would be created the first time you use the instance in Spawn(), and a clone of the clone will be created and pooled. As long as you use that same "source clone" to spawn again, it should work.

    It sounds like you want to go one step further and actually preload more clones of this clone. This should be possible as well, assuming the above, if you create a prefab pool in Awake() in a script and use the clone as the "prefab". These docs explain how to do this and give some C# example code: http://docs.poolmanager.path-o-logical.com/code-reference/spawnpool/spawnpool-createprefabpool

    There are some creative possibilities here that you might want to just play around with (and please let me know what you find out!). It all depends on if you want/need to do this through scripting or not. In theory, you could try adding an instance to your scene prior to run-time (which you have), and add a pre-runtime pool item component, then just duplicate that a bunch and start your game. All of these objects will be pooled and you can use them as normal. To protect the scenario, in the SpawnPool's inspector, you could set the "Per Prefab Pool Options" "Limit" option to the same number of instances as you have in your scene and no more will be created from the prefab. This means you have full control over the instances, because you made and altered them directly in the scene, and they will be spawned and despawned as you would expect.

    If you are not keeping the SpawnPool in a prefab, then you could try drag and dropping an instance in to the prefab slot in the SpawnPool options as well. I've never tried it but it may just work.

    Is this making sense?

    Let me know if I missed your point.
     
    Last edited: Oct 17, 2011
  25. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hello, just purchased this tool, and as soon as I import I get this:

    What to do?
     
  26. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Hi,

    Warnings should have no effect. You can ignore this and everything should work fine. It is annoying however, and I believe caused by us missing a variable that should have been deleted before release. This was an oversight and will be fixed soon. Thank you for reporting this.
     
  27. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hello,

    Im not quite understanding how to Spawn my objects,

    Do I call the pool item name like this:
    I'm so dense and confused right now since all I see in the docs is this:

    What is enemyPrefab?
     
  28. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    BTW, there isn't a video tutorial on how to do this?
     
  29. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    So I'm looking over the forums and one says I have to declare my prefab first, then enemyPrefab in the pool code calls this declared variable? I thought it was easier than that, since I already set up poolmanager on what prefab to pool, now I actually have to have multiple variables where I drag the same prefab in the inspector to call, isn't that kind of a lot of work? I have 10 things I need to call in script, means I have to declare 10 variables then setup up that same 10 variables for both the general script and the Poolmanager setup inspector. Clearly I am seriously confuse here...
     
  30. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    I think you are over-thinking this. It works the same way Instantiate does. Just pass in a reference to your prefab's transform. If you need further clarification, please post your code to our forums, or if you are worried about privacy, email support. Here is a link to our support page: support.path-o-logical.com.
     
  31. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    I most likely am, but its because of the way I am trying to understand. What's the point of using the inspector to pool say 10 of the same objects if its going to be used like the Instantiate function which doesn't require me to pool anything to do so. Where I am getting with this is, does declaring the object mean I will be using from the pool of 10 objects I created?
     
  32. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    I like the new Inspector Interface. This is definitely one of the extensions on my to-buy list :).
    Also, may I make a suggestion? Maybe to have the option to "mass add" items/entity to the pool manager from the inspector interface?
    Either by manually selectively pick items from the scene view, or perhaps add items from item list (much like 3DS MAX does when all avaliable items in scene are shown in a list and you can just pick them).
     
  33. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    If you add a pool in the inspector interface, then drag and drop a prefab, you get two things. First, you can use the options more easily, such as preload, via the inspector. Second, PoolManager will init with this pool which understands what prefab it is associated with. Then, when you run a Spawn() method with the same prefab, PoolManager knows how to handle it. It will either use an instance which already exists, or if one is not available, it will create a new one.

    [Edit] To clarify, you don't need to drag and drop anything for PoolManager to work. Creating a pool and using it in Spawn() will automatically create a PrefabPool the first time a prefab is used. You only need to use the inspector (or code) to create a PrefabPool when you want to use options such as preloading.

    Note that you don't have to use the inspector at all if you don't want to. You can do everything through code instead. Simply create a SpawnPool, and then use Spawn() from any script in your game as you would if you used the inspector. Here are the docs:
    http://docs.poolmanager.path-o-logi...ager/poolmanager-pools/poolmanager-createpool

    If you need to specify options, such as preload, then you will want to use CreatePrefabPool():
    http://docs.poolmanager.path-o-logical.com/code-reference/spawnpool/spawnpool-createprefabpool

    If I am still missing your question, please let me know. Are you wondering why you need to supply a reference as opposed to a string name? If so, references are faster and match the workflow in Unity. In most cases, adding PoolManager should be as simple as creating a pool (no need to even drag and drop a prefab unless you need the option) and replacing Instanciate() with Spawn() and Destroy() with Despawn(). The only consideration left may require a user to think about how they reset states on spawn, which is why a special function/callback is provided, OnSpawned() or OnDespawned().


    Interesting idea. My gut is to ask you to look in to the code way of doing this, which I mention above. If you have that many objects to deal with, it may be easier to ignore the inspector, keep all your settings in one script, and map your prefabs in a custom way. The reason I say this is because this isn't an action you would do more than once, and even if you had this, you would still need to adjust your options afterword. If you don't need the options, then you don't need this at all, because you don't need to drag and drop anything. Just use Spawn() and PoolManager will work automagically.

    Feel free to post to our forums or contact us via email if you need more custom information. If this idea for a scene multi-picker would really be beneficial, we can certainly look at it in more detail. I think you'll find you don't need this, but I am willing to eat my hat if we find this a nice improvement.


    Thanks for the posts!
     
    Last edited: Nov 21, 2011
  34. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Absolutely fantastic response! Thank you sir! :)
     
  35. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Actually it's simpler than that, sorry if it sounded confusing. I want to know if you can *not* use a Prefab - ie. use a standard GameObject instead. Might sound silly, but like I said I'm not a big fan of prefabs for a number of reasons. At most I use a prefab just a stepping stone or backup to my actual "prototype" (instantiated Game Object with all references properly set).

    I can't imagine how managing the instances from prefabs would differ from actual game objects, I just thought I'd ask 'coz the name "prefab" all around the interface makes it seem like it can't handle standard game objects. Sorry if it's a silly question :)
     
  36. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    I don't see why it wouldn't work. I know you can pass a GameObject to Instantiate, so PoolManager should accept it as well. Just make sure you use the same GameObject every time. Otherwise you'll end up with a clone of a clone of a clone, etc, and each will be a pool of 1. PoolManager just wants a reference to a Transform (or particle emitter - see the docs for more). It shouldn't matter beyond that.
     
  37. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hmm...I was gonna ask this over the forums but I seemed to be banned for spamming...weird since I only posted once the other day. Anyways, if I want to start creating my pools using script, I am quite confused on what to use. I saw in the script reference both CreatePool() and CreatePrefabPool() but I don't know which to use, also I tried using CreatPool() and I get this error:

    So I don't know where to go from here...
     
  38. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Figured out the problem, your docs have the code being CreatePool() instead of just Create()...and Create() didnt give an error so guess thats the right one...
     
  39. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Its so annoying that I have been permanently banned from the forums and I really did nothing and now I need to ask questions.

    So now I seem to be hitting the limit of the Pool Manager unless I have missed something.

    Here is my problem:

    I have enemies that fire different types of projectiles, how would I go about making sure my enemies are firing their specific projectile? I currently have a var that holds the prefab for each enemies projectiles which I just drag and drop...this var is in the EnemyControls script which each enemy has attached...
     
    Last edited: Nov 22, 2011
  40. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    First, sorry about the ban, I'll email you to fix it, I just need your username. We had around 15 new users creat accounts just to post spam and I must have added you to the bulk clean-up tool. My apologies.

    The docs are correct. That was new for version 2.0. Notice the docs are hierarchical, just like the classes. Create() is under Pools because it creates a new SpawnPool. CreatePrefabPool is under SpawnPool because PrefabPools are used by a spawn pool for prefab specific options and work. I believe these terms are discussed in the documentation in part 1 and 2, but part 3 is a good jumping off point for this, and shows the links more clearly as an object hierarchy: http://docs.poolmanager.path-o-logical.com/home/or-script-it . I'll add some clarity to this section when I get a chance.


    We'll gt you back on the forums ASAP, and then if you need further help, post some code and we will get it working.
     
  41. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    I assume you have something like a projectiles pool.. Just call spawn() on that pool and pass it the projectile prefab you want to spawn. Poolmanager will do the rest.

    Transform projectileInstance = PoolManager.Pools["Projectiles"].Spawn(projectilePrefab);

    [Edit] you should be un-banned now. Sorry again. I really don't get why people go through so much trouble to join our boards just to have their spam posts deleted. Sorry you got caught up in the clean-up.
     
    Last edited: Nov 22, 2011
  42. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Yes, I can log in now, thank you! I will create a new topic on the forums about this.
     
  43. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
  44. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hmm, if I am reading that correctly, I don't have to prespawn like 5 projectile particles? I should just let pool manager spawn the particle when needed?
     
  45. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Correct, you don't have to spawn anything you don't need. There are, however, two big benefits to using preloading:

    1. Unity will be forced to load all references needed to work with the instance (e.g. textures). This is why I usually will preload at least one of everything.

    2. PoolManager still uses Instantiate if there is no instance available to be spawned. So if I need 5 of something, all at once, then I will generally preload all 5, just so the overhead of Instantiate happens when the gameplay isn't intense.

    It is a balancing act, as it all development, between performance and memory, and unique to each game. Unspawned instances do not affect performance, but they are held in memory. I find this is usually OK though. Memory tends to be more plentiful than performance. If you do find memory is peaking, PoolManager offers a smart clean-up tool called Instance Culling.

    All of this is totally optional and is discussed here: http://docs.poolmanager.path-o-logical.com/home/per-prefab-options



    P.S. Sorry for the tapos (dammit, that term has been coined already! tapo = typo. Oh well...), I was on my iPad earlier.
     
  46. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    So I did this...

    Code (csharp):
    1. var projectileInstance = PoolManager.Pools["Enemy Projectiles"].Spawn(projectileParticle.transform, transform.position, Quaternion.identity);
    But when I despawn it, PoolManager doesnt seem to reuse it...the object gets spawned again?

    Ill post some code later.
     
  47. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    I see your post on our forums, so I'll answer there. In short, if the reference passed is a reference to the same Transform each time, it should just work. lets take a deeper look on the forums.

    Cheers,
     
  48. profanicus

    profanicus

    Joined:
    Nov 23, 2009
    Posts:
    295
    Hi, I have just purchased this the other day, very cool; and then of course 3.5 beta came out ... :)

    So I was wondering if you plan to update to support the 3.5 ParticleSystem class?

    I can Spawn them as Transforms, but they don't remove from the pool when dead.

    edit: well they don't seem to die at all, so I guess they need a script that sits on the particle and manually despawns when "isPlaying" is false?
     
    Last edited: Dec 24, 2011
  49. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Last edited: Dec 24, 2011
  50. profanicus

    profanicus

    Joined:
    Nov 23, 2009
    Posts:
    295
    Cool, until then it's pretty easy to add unofficially since you provide .cs and not dll :)

    I added functions to PoolManager's SpawnPool.cs to support 3.5 ParticleSystem, I can post here if it's allowed and anyone else wants or needs the mods.