版本: Unity 6 (6000.0)
语言英语
  • C#

MinMaxCurve

UnityEngine 中的结构体

/

实现于: UnityEngine.ParticleSystemModule

建议更改

成功!

感谢您帮助我们改进 Unity 文档的质量。虽然我们无法接受所有提交的内容,但我们会阅读用户提出的每个建议的更改,并在适用的情况下进行更新。

关闭

提交失败

由于某种原因,您的建议更改无法提交。请 <a>稍后再试</a>。感谢您抽出时间帮助我们改进 Unity 文档的质量。

关闭

取消

切换到手册

描述

最小-最大曲线的脚本接口。

最小-最大曲线。描述接受最小值和最大值之间的一个值并返回基于 ParticleSystem.MinMaxCurve.mode 的值的函数。根据模式,这可能会返回随机值。对于需要曲线的模式,返回的值取决于在粒子系统检查器中设计的曲线,该曲线可以评估为 -n 到 n 之间的单个值,其中 n 是也在检查器中设置的常数。有关更多信息,请参阅 ParticleSystemCurveMode

其他资源: ParticleSystem

using UnityEngine;

// This example shows setting a constant rate value. public class ConstantRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

GetValue(); SetValue(); }

void GetValue() { print("The constant value is " + emissionModule.rateOverTime.constant); }

void SetValue() { emissionModule.rateOverTime = 10.0f; } }
using UnityEngine;

// This example shows using 2 constants to drive the rate. public class TwoConstantsRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

GetValue(); SetValue(); }

void GetValue() { print(string.Format("The constant values are: min {0} max {1}.", emissionModule.rateOverTime.constantMin, emissionModule.rateOverTime.constantMax)); }

void SetValue() { emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(0.0f, 10.0f); } }
using UnityEngine;

// This example shows using a curve to drive the rate. public class CurveRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

// We can "scale" the curve with this value. It gets multiplied by the curve. public float scalar = 1.0f;

AnimationCurve ourCurve;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

// A simple linear curve. ourCurve = new AnimationCurve(); ourCurve.AddKey(0.0f, 0.0f); ourCurve.AddKey(1.0f, 1.0f);

// Apply the curve. emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(scalar, ourCurve);

// In 5 seconds we will modify the curve. Invoke("ModifyCurve", 5.0f); }

void ModifyCurve() { // Add a key to the current curve. ourCurve.AddKey(0.5f, 0.0f);

// Apply the changed curve. emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurve); } }
using UnityEngine;

// This example shows using 2 curves to drive the rate. public class TwoCurveRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

AnimationCurve ourCurveMin; AnimationCurve ourCurveMax;

// We can "scale" the curves with this value. It gets multiplied by the curves. public float scalar = 1.0f;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

// A horizontal straight line at value 1. ourCurveMin = new AnimationCurve(); ourCurveMin.AddKey(0.0f, 1.0f); ourCurveMin.AddKey(1.0f, 1.0f);

// A horizontal straight line at value 0.5. ourCurveMax = new AnimationCurve(); ourCurveMax.AddKey(0.0f, 0.5f); ourCurveMax.AddKey(1.0f, 0.5f);

// Apply the curves. emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax);

// In 5 seconds we will modify the curve. Invoke("ModifyCurve", 5.0f); }

void ModifyCurve() { // Create a "pinch" point. ourCurveMin.AddKey(0.5f, 0.7f); ourCurveMax.AddKey(0.5f, 0.6f);

// Apply the changed curve. emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax); } }
using UnityEngine;

// This example shows how to retrieve existing keys from a MinMaxCurve public class ReadCurveExample : MonoBehaviour { void Start() { // Get the system and the emission module. var myParticleSystem = GetComponent<ParticleSystem>(); var emissionModule = myParticleSystem.emission;

// Get the curve (assuming the MinMaxCurve is in Curve mode) AnimationCurve curve = emissionModule.rateOverTime.curve;

// Get the keys Keyframe[] keys = curve.keys; } }

属性

constant设置常数值。
constantMax设置上界的常数。
constantMin设置下界的常数。
curve设置曲线。
curveMax设置上界的曲线。
curveMin设置下界的曲线。
curveMultiplier设置应用于曲线的乘数。
mode设置最小-最大曲线用于评估值的模式。

构造函数

ParticleSystem.MinMaxCurve整个曲线的单个常数值。

公共方法

Evaluate手动查询曲线以根据其所在的模式计算值。