Version: 2022.1

描述

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

另请参阅: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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961