Hello,
I’m using a particle system that spawns 20 mesh particles (cubes) at once and throws them all over the place. When I spawn it for the first time I get a fairly huge spike lag - however, all spawns after this first initial one do not cause any lags (even if I spawn 3-4 of them simultaneously and I do not manually pool reuse the game objects at the moment). I guess Unity does some initialization of the particle system just-in-time when one is being spawned for the first time.
My question is what is the best idea to prevent this from happening. One simple solution would be to spawn one of the particle systems right at startup, pushing the initial lag to the first frame that is being rendered. However, I’m interested in what’s happening behind the scenes here and if there are better, less hacky approaches to fix it.
EDIT: The initial lag appears to be proportional to the number one enters in “Max Particles” in the particle system, so it is probably caused because Unity allocates this particle buffer when a particle system (of that type?) is being spawned for the first time. The initial question remains, is it possible to pre-allocate this without spawning one right at the start?