unity粒子系统 粒子特效播放完毕后自动销毁

作者:雨辰 发布于:2017-2-8 17:18 Wednesday 分类:Unity3D

using UnityEngine;
using System.Collections;
/// <summary>
/// 粒子系统 粒子特效播放完毕后自动销毁
/// </summary>
public class EQ_ParticleAutoDestruction : MonoBehaviour
{
    private ParticleSystem[] particleSystems;

    void Start()
    {
        particleSystems = GetComponentsInChildren<ParticleSystem>();
    }

    void Update()
    {
        bool allStopped = true;

        foreach (ParticleSystem ps in particleSystems)
        {
            if (!ps.isStopped)
            {
                allStopped = false;
            }
        }

        if (allStopped)
            GameObject.Destroy(gameObject);
    }
}

标签: Unity3D

发表评论:

雨辰 joyimp|@2011-2017 京ICP备16030765号