Version: 2017.2
public void SetVector (ParticleSystemCustomData stream, int component, ParticleSystem.MinMaxCurve curve);

参数

stream 要向其应用曲线的自定义数据流的名称。
component 要对其应用曲线的分量索引(0-3,映射到 Vector4 或 float4 的 xyzw 分量)。
curve 要用于生成自定义数据的曲线。

描述

设置 MinMaxCurve 以便生成自定义数据。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { ParticleSystem ps = GetComponent<ParticleSystem>(); var customData = ps.customData; customData.enabled = true;

AnimationCurve curve = new AnimationCurve(); curve.AddKey(0.0f, 0.0f); curve.AddKey(1.0f, 1.0f);

customData.SetMode(ParticleSystemCustomData.Custom1, ParticleSystemCustomDataMode.Vector); customData.SetVectorComponentCount(ParticleSystemCustomData.Custom1, 1); customData.SetVector(ParticleSystemCustomData.Custom1, 0, new ParticleSystem.MinMaxCurve(1.0f, curve)); } }