Particle Burst on Button Press

Hi. I just got over looking a particle systems in Unity and I need help figuring something out.

I’m currently using the Shuriken particle system in Unity 4. I’d like to sync a button press to trigger not only an increase of speed in my particle system, but trigger the particle burst feature. I’ve looked through the documentation on Unity’s website but it’s rather incomplete when it comes to Particle Systems. I’ve tried to code a few things and it’s become rather hit or miss as to whether Unity will accept the code for things, though I will admit I’m not the best programmer.

I’ve been taking a few small steps trying to learn how to program the particle system. So far, the most progress I’ve had is:

using UnityEngine;
using System.Collections;

public class particleOnOff : MonoBehaviour {

	// Use this for initialization
	void Start () {
	gameObject.particleSystem.enableEmission = false;
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown(KeyCode.JoystickButton0)) {
			
			gameObject.particleSystem.enableEmission = true;
		}
		
		
		/*if (gameObject.particleSystem.enableEmission = true && Input.GetKeyDown(KeyCode.JoystickButton0))  {
			gameObject.particleSystem.enableEmission = false;
		}*/
	}
}

Now I’m using a unique gamepad for this project, the Nintendo DK Bongos, which is why it’s reading joystick buttons, though I’ve also tested this with regular buttons. It works, but it only turns the particles on only. The commented out part is because I wanted to make the bongos turn emission on and off. Problem is that adding that commented part into the code makes it so the particle system won’t work at all. Adding a normal if or else statement after the first if statement doesn’t seem to work either. I consider this the first step to understanding the particle system, but I’m getting frustrated at getting these bursts to work. Can anyone help me?

Have you took a look at ParticleSystem.Emit( count:int )?

If you need a quick burst of 10 particles when you click

public class ParticleController : MonoBehaviour {

	void Start () {
		// You can use particleSystem instead of
		// gameObject.particleSystem.
		// They are the same, if I may say so
		particleSystem.emissionRate = 0;
	}
	
	void Update () {
		if( Input.GetKeyDown( KeyCode.A ) ) {
			particleSystem.Emit(10);	
		}
	}
}

if you need X number of particles per second while touching:

if (Input.GetKey(KeyCode.A)) {
   particleSystem.Emit( (int) (particlePerSecond * Time.deltaTime) );
}