0

I am having trouble trying to enable/disable the emitter during runtime. I would like to be able to click on the emitter and have it turn on/off accordingly. I know how to call Input.GetMouseDown(0), but I do not know how to set the emitter. I tried using gameObject.particleEmitter.enabled, but that didn't work unfortunately.

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
unbootabru
  • 347
  • 1
  • 3
  • 9

2 Answers2

0

1) You have to use GameObject.GetComponent: http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html

2) and then ParticleEmitter.enabled: http://docs.unity3d.com/ScriptReference/ParticleEmitter-enabled.html

Dave
  • 2,684
  • 2
  • 21
  • 38
0

If you want to click on the emitter, first of all, the emitter game object has to have a Collider component. It can be 2d or 3d collider of various forms, depending on what exactly do you want. Then, the modern way of implement IPointerClickHandler interface, and ensure that you have an EventSystem and a relevant Raycaster (2d or 3d, depending on what collider are you using) present in the scene.

Max Yankov
  • 12,551
  • 12
  • 67
  • 135