Changing Color of Particles in Javascript


I've created the option of color customisation using some GUI Sliders and the `renderer.material.color` command thingy. However, that only works with materials (obviously). To get it to change the color of a particle system, I tried what the Unity Script Reference said to do:

function Start ()
var modifiedColors : Color[] = particleAnimator.colorAnimation;
modifiedColors[2] = ColorCustGlow.glowColor; //My color is a static variable in another script
particleAnimator.colorAnimation = modifiedColors;

But that didn't work - Unity had no idea what `particleAnimator` was. I also tried to put `GetComponent` in there, but that didn't help at all. Is there something obvious I'm missing??

PS. I also tried it without my reference to another script, but instead `Color.yellow`, and it still didn't work...

Not every component has a shortcut; you'd have to use GetComponent(ParticleAnimator). (So the script example in the docs isn't correct.)