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 prewarm option not enabled, play not start emitting particles (not sure why happens)
  • the isplaying property remain true along there active particles in scene. once these die, set false
  • the stop method not destroy particles active in scene
  • if particlesystem has stopped , call play while there particles active in scene, active particles destroyed , particlesystem starts emitting new set of particles

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -