Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


colorBySpeed

Script interface for the ColorByLifetimeModule of a Particle System.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.ParticleSystemModule
public ParticleSystem.ColorBySpeedModule colorBySpeed { get; }

Remarks

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.

Examples

using UnityEngine;using System.Collections;[RequireComponent(typeof(ParticleSystem))]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(Color.blue, 0.0f), new GradientColorKey(Color.red, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) } ); col.color = grad; }}