Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ParticleSystem.customData

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var customData: ParticleSystem.CustomDataModule;

Description

Access 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.

See Also: ParticleSystemRenderer.EnableVertexStreams.

no example available in JavaScript
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, UnityEngine.ParticleSystemCustomDataMode.Color); customData.SetColor(ParticleSystemCustomData.Custom1, grad); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答