当粒子和系统停止时,选择是否禁用或销毁游戏对象,抑或调用 MonoBehaviour.OnParticleSystemStopped 脚本回调。
using UnityEngine; using System.Collections;
[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps;
void Start() { ps = GetComponent<ParticleSystem>(); ps.Stop();
var main = ps.main; main.loop = false; main.duration = 1.0f; main.stopAction = ParticleSystemStopAction.Destroy;
ps.Play(); } }