According to below ParticleSystem.startLifetime reference, ParticleSystem.startLifetime can set value by “Curve”.
In the Unity Inspector, I can set its value by following 4 ways.
- Constant
- Curve
- Random Between Two Constants
- Random Between Two Curves
But in C# script, I can’t find the way except for Constant.
How do I set its value by “Curve”, “Random Between Two Constants” or “Random Between Two Curves” ?
For example following codes has error "Error : Cannot convert from UnityEngine.AnimationCurve to System.Single ".
var particleSystem = gameObject.AddComponent<ParticleSystem>();
var curve =new AnimationCurve();
curve.AddKey(0,0);
curve.AddKey(1,1);
particleSystem.startLifetime = curve;