控制粒子系统在世界中移动时如何计算其速度。
using UnityEngine; using System.Collections;
[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public ParticleSystemEmitterVelocityMode velocityMode;
void Start() { ps = GetComponent<ParticleSystem>(); }
void Update() { var main = ps.main; main.emitterVelocityMode = velocityMode; }
void OnGUI() { velocityMode = (ParticleSystemEmitterVelocityMode)GUI.SelectionGrid(new Rect(25, 25, 300, 30), (int)velocityMode, new GUIContent[] { new GUIContent("Transform"), new GUIContent("Rigidbody") }, 2); } }