Particle system stop?

Hello,

I’m just using one of the unity built in particle effects, the soap bubbles but can’t get the particles to stop playing. I had this working in another project so I’m not sure if the more recent version of Unity has affected this.

I tried applying this script to the particle system:

using UnityEngine;
using System.Collections;

public class Bubbles : MonoBehaviour 
{

	void Start () 
	{
		particleSystem.Stop();
	}
}

I Get the error:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.ParticleSystem.Stop (Boolean withChildren) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:496)
UnityEngine.ParticleSystem.Stop () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:488)
Bubbles.Start () (at Assets/Bubbles.cs:9)

Your script doesn’t have reference to the particle system. Create add this public variable to the top of your script.

public ParticleSystem particleSystem;

and then drag the particle system into that Bubbles script in the Inspector.

Thanks for the advice again, I know you can’t drag a particle onto an asset directly in the project window, I was trying it on the Main Camera, Particle system itself and an empty game object with the particle parented. For some reason when I’ve tried again with:

using UnityEngine;
using System.Collections;

public class Bubbles : MonoBehaviour 
{
	public ParticleSystem particleSystem;
	
	void Start () 
	{
		particleSystem.Stop();
	}
}

I get a null reference again.

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.ParticleSystem.Stop (Boolean withChildren) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:496)
UnityEngine.ParticleSystem.Stop () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:488)
Bubles.Start () (at Assets/Bubles.cs:10)

I also get this message when I save the code from MonoDevelop.

Assets/Bubles.cs(6,31): warning CS0108: `Bubles.particleSystem' hides inherited member `UnityEngine.Component.particleSystem'. Use the new keyword if hiding was intended

GetComponent().Stop();
GetComponent().Play();