unity3d - Unity particle system only plays if i hit SIMULATE button -
i have prefab particle system attached. in code play particle using code
ps.enableemission = true; when run game, , code executes, particle emitter not emit in "game" window unless press simulate button in "scene" window.
anybody knows why?
for emission property work particle system has playing. can either enable play on awake in particlesystem component or use play method on instance of particlesystem component.
as side note, if using 5.3+ enableemission property obsolete , may want consider using emission property. 1 thing keep in mind when using property have assign variable before attempting modify it:
public particlesystem _ps; ... private void update() { particlesystem.emissionmodule module = _ps.emission; module.enabled = true; } update #1
in response tractor beam example in comments suggest using setactive on game object has particlesystem component. using setactive prevent particles being emitted , destroy active, i.e. in scene.
if use emission property, prevent emission of particles, not destroy have been emitted.
one other approach use play , stop methods these, emission property, not destroy active particles. if use these methods, things watch out are:
- if
prewarmoption not enabled,playnot start emitting particles (not sure why happens) - the
isplayingproperty remaintruealong there active particles in scene. once these die, setfalse - the
stopmethod not destroy particles active in scene - if
particlesystemhas stopped , callplaywhile there particles active in scene, active particles destroyed ,particlesystemstarts emitting new set of particles
Comments
Post a Comment