Version: 2017.3
public void SetColor (ParticleSystemCustomData stream, ParticleSystem.MinMaxGradient gradient);

参数

stream 要向其应用渐变的自定义数据流的名称。
gradient 要用于生成自定义颜色数据的渐变。

描述

设置 MinMaxGradient 以便生成自定义 HDR 颜色数据。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { ParticleSystem ps = GetComponent<ParticleSystem>(); var customData = ps.customData; customData.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) });

customData.SetMode(ParticleSystemCustomData.Custom1, ParticleSystemCustomDataMode.Color); customData.SetColor(ParticleSystemCustomData.Custom1, grad); } }