Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


color

The gradient that controls the particle colors.
Read time 1 minuteLast updated 12 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.ParticleSystemModule
public ParticleSystem.MinMaxGradient color { get; set; }

Remarks

Additional Resources: ParticleSystem.MinMaxGradient.

Examples

using UnityEngine;using System.Collections;[RequireComponent(typeof(ParticleSystem))]public class ExampleClass : MonoBehaviour{ private ParticleSystem ps; public float hSliderValue = 1.0f; void Start() { ps = GetComponent<ParticleSystem>(); var colorOverLifetime = ps.colorOverLifetime; colorOverLifetime.enabled = true; Gradient gradient = new Gradient(); gradient.SetKeys( new GradientColorKey[] { new GradientColorKey(Color.green, 0.0f), new GradientColorKey(Color.red, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(1.0f, 1.0f) } ); colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient); } void Update() { var main = ps.main; main.startLifetime = hSliderValue; } void OnGUI() { hSliderValue = GUI.HorizontalSlider(new Rect(25, 45, 100, 30), hSliderValue, 1.0f, 5.0f); }}