如何在Unity中启动和停止粒子系统? [英] How to start and stop a particle system in Unity ?
问题描述
我正在使用Unity 5.3x进行游戏.我有一个具有以下对象结构的Prefab
I'm using Unity 5.3x for a game. I've a Prefab with the following structure hirerchy of object
MyPrefab-> MyContainer-> NitroEffect-> NitroFlamethrowerFire
MyPrefab -> MyContainer -> NitroEffect -> NitroFlamethrowerFire
我在如何播放停止粒子系统方面遇到问题.我正在使用以下代码,但是(不要笑)有时可以工作,有时不能,而且我也不知道为什么.
I'm having problem on how to Play Stop Particle System. I'm using the following code, but (don't laugh) sometimes works, sometimes not, and i don't know why.
Container = transform.Find ("MyContainer").gameObject;
PS_Nitro = Container .transform.FindChild("NitroEffect/NitroFlamethrowerFire").GetComponent(); PS_Nitro.enableEmission = false; //to stop emission
And
PS_Nitro.enableEmission = true; // to start emission
所以我的问题是:如何开始正确停止粒子发射?
So my question is: how to start stop properly a Particle emission ?
推荐答案
就是这样-enableEmission
属性.
您所需要的只是保存到粒子系统的链接,而不必在每次必须启动/停止它时都进行搜索.
All you need is just to save the link to the particle system and not search for it each time you have to start/stop it.
只需将您对PS_Nitro
的引用保存到某个变量中,以后再使用.
Just save your reference for PS_Nitro
to some variable and use it later on.
这篇关于如何在Unity中启动和停止粒子系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!