Select your preferred scripting language. All code snippets will be displayed in this language.
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.
CloseFor 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.
Closestream | The name of the custom data stream to enable data generation on. |
mode | The type of data to generate. |
Choose the type of custom data to generate for the chosen data stream.
#pragma strict function Start() { var ps: ParticleSystem = GetComponent.<ParticleSystem>(); var customData: var = ps.customData; customData.enabled = true; var grad: Gradient = new Gradient(); grad.SetKeys([new GradientColorKey(Color.blue, 0.0f), new GradientColorKey(Color.red, 1.0f)], [new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f)]); customData.SetMode(ParticleSystemCustomData.Custom1, ParticleSystemCustomDataMode.Color); customData.SetColor(ParticleSystemCustomData.Custom1, grad); var curve: AnimationCurve = new AnimationCurve(); curve.AddKey(0.0f, 0.0f); curve.AddKey(1.0f, 1.0f); customData.SetMode(ParticleSystemCustomData.Custom2, ParticleSystemCustomDataMode.Vector); customData.SetVectorComponentCount(ParticleSystemCustomData.Custom2, 1); customData.SetVector(ParticleSystemCustomData.Custom2, 0, new ParticleSystem.MinMaxCurve(1.0f, curve)); }
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);
AnimationCurve curve = new AnimationCurve(); curve.AddKey(0.0f, 0.0f); curve.AddKey(1.0f, 1.0f);
customData.SetMode(ParticleSystemCustomData.Custom2, ParticleSystemCustomDataMode.Vector); customData.SetVectorComponentCount(ParticleSystemCustomData.Custom2, 1); customData.SetVector(ParticleSystemCustomData.Custom2, 0, new ParticleSystem.MinMaxCurve(1.0f, curve)); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information