I have an explosion visual effect that was given to me by a third party artist/developer (so I don’t know the design of it inside and out). It’s relatively simple in construction - a single prefab consisting of a game object and two children, with each game object containing a particle system (so 3 systems in total). One of the systems emits 100 particles using Unity’s standard Cube mesh with trails, using the standard Mobile/Particles/Alpha Blended shader. One system emits 3 particles of a billboarded texture (32x32) using a custom shader (which looks relatively simple). The third system emits a single particle using a mesh which looks kind of like a blocky cloud (528 verts, 180 tris), using a different custom shader (also pretty simple-looking).
On scene load I instantiate a single instance of this prefab, which starts deactivated. Periodically (and relatively rarely) the player collects a gem, and I move the instance to that location and activate it (the particle systems are all set to Play On Awake), and then deactivate it after a few seconds (by which time the effects have died away). It all works fine, except that on all the iOS devices I’ve tested on, there is a noticeable framerate hitch the first time the effect is played after opening the app. After that, I never notice a delay.
What are the likely causes of this delay, and how might I diagnose/eliminate it? (I’ve tried using the Unity profiler and Xcode tools, but I don’t know what to look for.) For instance, might it have something to do with the texture being sent to the GPU for the first time? (It’s a small texture, so that seems unlikely.) Something to do with the mesh being displayed for the first time? Is there anything else in my above description that suggests a problem?
I did try running the effect once on scene startup (but putting it out of sight behind other objects in the scene) to try to “preload” whatever the problem is, and this did seem to eliminate the delay some of the time, but not all of the time. This just adds to my confusion, because I don’t know what’s different about the cases in which this solution works and those in which it doesn’t.