- Home /
Question by
luniac · Dec 10, 2014 at 07:24 PM ·
particle systemshurikenduration
why is particle system duration read only?
Is there any way i can it via script?
Comment
Best Answer
Answer by smoggach · Dec 10, 2014 at 09:24 PM
No there is not. You would have to re-create the entire particle system.
I bet there are other particle plugins out there that you can get who have dynamic particle systems though, if that's what you really need.
naa it's a very very $$anonymous$$or issue, almost a non issue at all. But thanks :)
Answer by Oswego · Apr 15, 2017 at 07:57 AM
Actually there is a way and it is in the documentation:
public class ExampleClass : MonoBehaviour
{
private ParticleSystem ps;
void Start()
{
ps = GetComponent<ParticleSystem>();
ps.Stop(); // Cannot set duration whilst particle system is playing
var main = ps.main;
main.duration = 10.0f;
ps.Play();
}
}
You can use the main object attached to the particle systems.
https://docs.unity3d.com/ScriptReference/ParticleSystem.MainModule-duration.html