I’m referring to the nice Gradient Editor available on the new shuriken particle system. Is it possible to use that as a variable I can have in the inspector for my own scripts? I could see it working similar to the existing AnimationCurve variable.
currentColor = colorGradient.Evaluate(0.5f);
(this would grab whatever color is at the halfway point in the gradient)
edit: I guess it might be possible for me to set up a dummy particle with the gradient I want and just read the color of the particle.
Well that looks like a dead end… ParticleSystem.Particle.color doesn’t give me the actual color of the particle (which is controlled by color over lifetime), it only gives me the starting color. Is that intended…? Doesn’t seem very useful.
edit: to get around it, I’m creating/destroying particles as close to 30fps as I can get so that they get a new starting color over time that I can read. Still has a flickering problem though. So many hoops to jump through to do what I want -_-
Well it is useful if you have one prefab of your effect but need the effect to be a different color sometimes without having to make a prefab for each color you are using.
However, I agree with you, having access to the gradient would be great as it would allow more options.
Man, I would totally love to have access to Shuriken’s gradient class. I wouldn’t even be using it for shuriken most of the time. I’d most likely use it in place of Color.Lerp() (or a series of them).
It seems like there’s an undocumented class UnityEngine.Gradient that uses the gradient inspector if declared as a public member of a MonoBehaviour. It has an Evaluate(float) method and steps can be added programmatically.