Complete the code to set the particle system's start color to red.
var ps = GetComponent<ParticleSystem>();
var main = ps.main;
main.startColor = [1];The startColor property sets the initial color of particles. Using Color.red sets it to red.
Complete the code to enable size over lifetime module.
var ps = GetComponent<ParticleSystem>();
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.[1] = true;startSize which is not a property of the module.startColor here.The enabled property activates the size over lifetime module.
Fix the error in setting the color gradient for color over lifetime.
var ps = GetComponent<ParticleSystem>();
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
colorOverLifetime.color = new ParticleSystem.MinMaxGradient([1]);Color directly instead of a Gradient.The color property expects a MinMaxGradient which can be created from a Gradient object, not a simple Color.
Fill both blanks to set size over lifetime curve and enable it.
var ps = GetComponent<ParticleSystem>(); var sizeOverLifetime = ps.sizeOverLifetime; sizeOverLifetime.[1] = new ParticleSystem.MinMaxCurve(AnimationCurve.EaseInOut(0, 0, 1, 1)); sizeOverLifetime.[2] = true;
startSize which is not a property here.The size property sets the size curve, and enabled turns on the module.
Fill all three blanks to set a color gradient with two color keys and enable color over lifetime.
var ps = GetComponent<ParticleSystem>();
var colorOverLifetime = ps.colorOverLifetime;
var gradient = new Gradient();
gradient.colorKeys = new GradientColorKey[] {
new GradientColorKey([1], 0.0f),
new GradientColorKey([2], 1.0f)
};
gradient.alphaKeys = new GradientAlphaKey[] {
new GradientAlphaKey(1.0f, 0.0f),
new GradientAlphaKey(0.0f, 1.0f)
};
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
colorOverLifetime.[3] = true;The gradient starts with red at time 0 and ends with yellow at time 1. The enabled property activates the color over lifetime module.