- Home /
The question is answered, right answer was accepted
Scaling ParticleSystem Emission rate to mesh size
I have started doing some optimization on a particularly heavy addition to a game I'm working on and through use of the profiler I see that one of the heaviest single operations happening is modification of a ParticleSystem. I have a ParticleSystem whose emission is on a MeshRenderer whose shape and size is changing a lot. Trying to keep the visual aspect of the ParticleSystem consistent by modifying it to consider the edges/triangles/vertices in the mesh works, but it is a huge drain on framerate. In one example in the moment that the number of triangles in the mesh stops changing the framerate will jump from 20 to 60 (the 60 is vsynced from what I can tell, this is in a built version of the game so it is faster than what I would see in the editor with the profiler running).
Is there a way to change the settings of the ParticleSystem more efficiently if I can't predict future changes to create a MinMaxCurve, or is there a setting of the ParticleSystem itself that I can change so that the ParticleSystem doesn't try to optimize on the assumption that its settings are static. For example, would turning prewarm off increase efficiency because it doesn't need to calculate the entire duration of the loop every time it is changed.
Answer by Pafk · Jun 17, 2017 at 04:56 PM
After more experimentation and research I found my answer
if (!ps.emission.rateOverTime.Equals(new ParticleSystem.MinMaxCurve(scale)))
{
ParticleSystem.MaxMinCurve curve = ps.emission.rateOverTime;
curve.mode = ParticleSystemCurveMode.Constant;
curve.constant = scale;
}
is much more efficient than
if (!ps.emission.rateOverTime.Equals(new ParticleSystem.MinMaxCurve(scale)))
{
emission.rateOverTime = scale;
}
Follow this Question
Related Questions
How to emit particles in one direction only? 1 Answer
Ship or any object made of smoke? 0 Answers
ParticleSystem.emission randomly wont reset 1 Answer
3d mesh glitch in particle system (mesh reduction when sizing down to 0) 1 Answer
Particle System: Material doesn't cover the entire sphere mesh 1 Answer