U3d 粒子自动销毁

来源:互联网 发布:p2p运营数据分析 编辑:程序博客网 时间:2024/05/21 10:33
using System.Collections;using System.Collections.Generic;using UnityEngine;//挂在最上层的粒子上,自己和下边的粒子全部播放结束,删除public class des : MonoBehaviour{    ParticleSystem[] particles;    void Start()    {        particles = GetComponentsInChildren<ParticleSystem>();    }    void Update()    {        bool allStop = true;        foreach (var par in particles)        {            if (par.isPlaying)            {                allStop = false;                break;            }        }        if (allStop)        {            Destroy(this.gameObject);        }    }}