So I have a mesh, I instantiate this prefab/mesh on a regular basis every 3 seconds as a new object. They destroy themselves every 4 or 5 seconds later to clean up.
Problem is (on the iPhone) the whole game freezes for a moment while that object is instantiated. I notice that each object adds a draw call also.
Question is basic strategy. If I need lots of objects, using the same prefab/mesh what is the best way to introduce them to the scene? Is there a way to prevent separate draw calls for each one?
I've thought about instantiating a bunch on load and hide them off camera. Showing and hiding as needed, but I would still require a bunch of draw calls for the objects I think.
So I have a mesh, I instantiate this
prefab/mesh on a regular basis every 3
seconds as a new object. They destroy
themselves every 4 or 5 seconds later
to clean up.
That's what is killing your performance; instantiate your objects on Start() and then disable the ones you don't need. Things off camera will not cost you draw calls; your last comment about showing/hiding is what you want to do. Excessive Destroy() calls will just lead to Garbage Collection while your scene is running, and the frame rate will stutter significantly.
If I need lots of objects, using the
same prefab/mesh what is the best way
to introduce them to the scene? Is
there a way to prevent separate draw
calls for each one?
Objects with a relatively low face count and sharing the same material will be dynamically batched, meaning 1 draw call. Other options include combining meshes (CombineChildren script, for example).
The Reference Manual has a dedicated section on Graphics optimization: Graphics Optimization