{"assets":[],"author_link":"author\/quill18\/","author_name":"quill18","cat":"LD #32","categories":["LD #32"],"comments":[],"epoch":1429147620,"event":"LD32","likes":8,"metadata":{"p_key":"83340","p_author":"quill18","p_authorkey":"0","p_urlkey":"294078","p_title":"Simple Pooling for Unity","p_cat":"LD #32","p_event":"LD32","p_time":"1429147620","p_likes":"8","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1429228800","event_key":"27","event_name":"LD32"},"source_url":"2015\/04\/16\/simple-pooling-for-unity\/","text":"<p>I made a thing. \u00a0It might be helpful for people.<\/p>\n<p><a href=\"https:\/\/gist.github.com\/quill18\/5a7cfffae68892621267\">https:\/\/gist.github.com\/quill18\/5a7cfffae68892621267<\/a><\/p>\n<p>Instantiating &amp; Destroying large numbers of objects (bullets or large hordes of enemies) can sometimes cause a game to stutter during their creation or later during garbage collection. \u00a0Object Pooling counters this by simply deactivating objects instead of destroying them, then re-activating them when you need a new copy.<\/p>\n<p>All the pooling solutions for Unity I could find seemed overwrought and often required a bunch of advanced setup on a prefab-by-prefab basis. \u00a0The solution I\u2019ve come up with simply requires you to use SimplePool.Spawn() and SimplePool.Despawn() instead of Instantiate() and Destroy(). \u00a0Pool sizes automatically grow to meet demand. \u00a0There is an option to preload objects if you know you\u2019re going to need to spam out a bunch of something very quickly (for example, projectiles for a bullet-hell shmup).<\/p>\n<p>WARNING: NOT YET TESTED IN A FULL PRODUCTION APPLICATION.<\/p>","time":"April 16th, 2015 1:27 am","title":"Simple Pooling for Unity","title_was_empty":false}