Unity 粒子ParticleSystem正确的关闭方式
来源:互联网 发布:全面战争优化9圣物 编辑:程序博客网 时间:2024/06/08 11:15
Unity 粒子ParticleSystem正确的关闭方式
using System;using System.Collections;using UnityEngine;using Random = UnityEngine.Random; public class ParticleSystemDestroyer : MonoBehaviour { //允许一个粒子系统在指定的时间存在, //然后关闭发射,并等待所有粒子到期 //破坏前的游戏对象 public float minDuration = 8; public float maxDuration = 10; private float m_MaxLifetime; private bool m_EarlyStop; private IEnumerator Start() { var systems = GetComponentsInChildren<ParticleSystem>(); // find out the maximum lifetime of any particles in this effect foreach (var system in systems) { m_MaxLifetime = Mathf.Max(system.main.startLifetime.constant, m_MaxLifetime); } // wait for random duration float stopTime = Time.time + Random.Range(minDuration, maxDuration); while (Time.time < stopTime || m_EarlyStop) { yield return null; } Debug.Log("stopping " + name); // turn off emission foreach (var system in systems) { var emission = system.emission; emission.enabled = false; } BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver); // wait for any remaining particles to expire yield return new WaitForSeconds(m_MaxLifetime); Destroy(gameObject); } public void Stop() { // stops the particle system early m_EarlyStop = true; } }
阅读全文
0 0
- Unity 粒子ParticleSystem正确的关闭方式
- Unity粒子系统 Unity3D ParticleSystem粒子系统(3.5版)
- iOS_31_cocos2d_粒子系统ParticleSystem
- ParticleSystem粒子系统
- Unity3D ParticleSystem粒子系统
- 关于Unity ParticleSystem的一些"冷"知识
- 关闭线程的正确方式?
- Unity3D ParticleSystem粒子系统 【初级】
- 模拟粒子系统(ParticleSystem.Simulate)
- unity particleSystem bug研究
- 【Unity】ParticleSystem 介绍
- cocos2dx中关于粒子系统(particleSystem)的一些属性的设置
- Unity3D中代码控制粒子移动或者按照预定的路径移动(ParticleSystem)
- Unity3D ParticleSystem粒子系统(3.5版)
- Unity3D ParticleSystem粒子系统(3.5版
- Unity3D ParticleSystem粒子系统属性总结
- Unity3D ParticleSystem粒子系统属性总结
- mfc关闭模态dialog的正确方式
- .NET Core 使用RabbitMQ
- 18、Selenium + Python 实现 UI 自动化测试-Property、Attribute、text区别
- Bootstrap Table 表格参数详解
- mysql不能远程连接
- Java多线程系列--“JUC集合”06之 ConcurrentSkipListSet
- Unity 粒子ParticleSystem正确的关闭方式
- 01.JAVA并发编程-线程的使用-基本概念
- Unity3d打包apk出现的问题
- c++ primer 第五版----第七章习题解答
- 国内这家公司瞬间在美国火了
- 新iPhone的一大波吐槽正在袭来
- 程序员的祖师爷到底有多么牛逼?
- 《聊斋志异》里记载过这样一个程序员的故事……
- 移居美国:那些不会有人告诉你的事实