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

ParticleSystem.InheritVelocityModule.curve

建议更改

成功!

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

关闭

提交失败

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

关闭

取消

切换到手册

描述

曲线用于定义在粒子生命周期内系统应用发射器速度的多少。

其他资源: MinMaxCurve.

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public bool isEnabled = true; public float hSliderValue = 5.0f; public ParticleSystemInheritVelocityMode inheritMode;

void Start() { ps = GetComponent<ParticleSystem>();

var main = ps.main; main.simulationSpace = ParticleSystemSimulationSpace.World; // rate over distance only works for world space simulations

// add a sphere so we can see our transform position as it moves var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.parent = ps.transform; }

void Update() { var inheritVelocity = ps.inheritVelocity; inheritVelocity.enabled = isEnabled; inheritVelocity.curve = hSliderValue; inheritVelocity.mode = inheritMode;

ps.transform.position = new Vector3(Mathf.Sin(Time.time * 2.0f) * 2.0f, 0.0f, 0.0f); }

void OnGUI() { isEnabled = GUI.Toggle(new Rect(25, 45, 100, 30), isEnabled, "Enabled"); hSliderValue = GUI.HorizontalSlider(new Rect(25, 85, 100, 30), hSliderValue, 0.0f, 10.0f); inheritMode = (ParticleSystemInheritVelocityMode)GUI.SelectionGrid(new Rect(25, 125, 300, 30), (int)inheritMode, new GUIContent[] { new GUIContent("Initial"), new GUIContent("Current") }, 2); } }