Version: 2019.1
public ParticleSystem.CustomDataModule customData ;


Script interface for the Particle System Custom Data module.

Once configured, this module will generate custom per-particle data, which you can use either in script or shaders. To read the data from script, simply call ParticleSystem.GetCustomParticleData. To read it in a shader, enable the custom data streams in the ParticleSystemRenderer Module, or call ParticleSystemRenderer.EnableVertexStreams from script. Once enabled, the custom data will be passed to your vertex shader through a TEXCOORD channel. The ParticleSystemRenderer Inspector will tell you which channels are being used.

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

関連項目: ParticleSystemRenderer.EnableVertexStreams.

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(, 0.0f), new GradientColorKey(, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) });

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