- Home /
Which is faster for a pool of objects, instantiating and adding to an array or loading pre-made objects to an array?
For a pool of objects, is it less expensive to instantiate them all on Awake() and slug them into an array or to load an already existing pool and array them?
Instantiating a large number of objects on Start() may hit performance but so does having to find a large number of pre made objects before adding to an array.
Came across this handy script in the forums for FindingByTag which, from what I understand, would be faster than FindingByName: link text
I'm wondering if anyone's done any comparisons with Instantiating vs. FindingByTag?
Answer by Nanity · Aug 06, 2012 at 07:47 AM
I can't judge performance with solid evidence, but if the objects already exist as you say, finding by tag may be the better alternative. Initiating on awake doubles the amount of (big) object and needs more time and memory than searching the object reference.
But I wonder how there's a pre-existing pool of objects if you are just going to load you scene? If they are instantiated anywhere else at the same time, delete them out over there and move it all to one script, both instantiation and array listing.