Reputation: 189
Hopefully a simple question. I want to change the two start colors for the 'random between two colors' start colors in the particle system component, using C# in unity, however, can't seem to figure out how.
Here is the code I thought would do it, but it does not:
void Start () {
Color particleMax = gameObject.GetComponent<ParticleSystem> ().main.startColor.colorMax;
particleMax = Color.red;
Color particleMin = gameObject.GetComponent<ParticleSystem> ().main.startColor.colorMin;
particleMin = Color.white;
}
Upvotes: 1
Views: 2517
Reputation: 2842
Color in Unity3D is a value type (struct) not a reference type. If you want to set the gradient try this instead:
void Start () {
ParticleSystem.MainModule psMain = GetComponent<ParticleSystem>().main;
psMain.startColor = new ParticleSystem.MinMaxGradient(Color.white, Color.red);
}
Upvotes: 3