public ParticleSystem.ColorBySpeedModule colorBySpeed ;


Script interface for the ColorByLifetimeModule of a Particle System.

This module assigns colors to the particles based on the speed that they are travelling.

Particle System modules do not need to be reassigned back to the system; they are interfaces and not independent objects.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { ParticleSystem ps = GetComponent<ParticleSystem>(); var col = ps.colorBySpeed; col.enabled = true;

Gradient grad = new Gradient(); grad.SetKeys( new GradientColorKey[] { new GradientColorKey(, 0.0f), new GradientColorKey(, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) } );

col.color = grad; } }