- Home /
Having Trouble Editing a Particle's "Size over Lifetime" via Script (JS)
This might be a dumb question, but I don't use particles much so I'm very inexperienced with them. I'm trying to edit a Particle System's 'Y' curve for its Size over Lifetime via script, but I'm not sure how I would access it. I want to have this new Y curve displayed in the inspector, just how it would if I used:
var newCurve : AnimationCurve;
The problem is, Size over Lifetime is not an animation curve. Basically, I'm just wondering what type of "curve" I would need to declare it as?
Answer by ifurkend · May 30, 2017 at 03:43 AM
You cannot edit the exact curve via script, either JS or C#. It must be done in the editor UI. Your can only change the curve multiplier, IOW, the curve range, via script.
using UnityEngine;
public class test : MonoBehaviour {
ParticleSystem ps;
ParticleSystem.SizeOverLifetimeModule psSol;
public float psSolY = 5f;
void Start() {
ps = GetComponent<ParticleSystem>();
psSol = ps.sizeOverLifetime;
}
void Update() {
psSol.yMultiplier = psSolY;
}
}
Answer by Spydrouge · Mar 23, 2021 at 01:58 PM
While ifurkend's answer may have been correct in 2017, this answer (and it's solution) are still getting searched in 2021, where the size over lifetime can definitely be set by an animation curve. See here:
https://docs.unity3d.com/2021.1/Documentation/ScriptReference/ParticleSystem-sizeOverLifetime.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612123054im_/https://answers.unity.com/themes/thub/images/avi.jpg)