# Play

> Starts the Particle System.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.ParticleSystemModule

## Play(bool)

Starts the Particle System.

```csharp
public void Play(bool withChildren)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Play all child Particle Systems as well.

### Remarks

Sets the Particle Systems into play mode and enables emitting (if it has been disabled).

If the Particle System has been **paused**, then this resumes playing from the previous time.

If the Particle System has **stopped**, then the system starts from time 0, and, if it is relevant, the [ParticleSystem.startDelay](/engine/6000.0/script-reference/unityengine/particlesystem/startdelay.md) is applied. If the Particle System is **already playing**, the system continues to play and this function has no effect.

**Note**: Unity does not apply [ParticleSystem.MainModule.prewarm](/engine/6000.0/script-reference/unityengine/particlesystem/mainmodule/prewarm.md) when the Particle System resumes from a paused state. To apply `prewarm` when the Particle System resumes, call [ParticleSystem.Clear](/engine/6000.0/script-reference/unityengine/particlesystem/clear.md) after [ParticleSystem.Stop](/engine/6000.0/script-reference/unityengine/particlesystem/stop.md).

**Note**: If you invoke this function again before the particle system has had time to spawn a particle, the particle system restarts its internal counters. This means that if you invoke this function continuously, a particle system with a low emission rate will never start to play.

Additional Resources: [ParticleSystem.Stop](/engine/6000.0/script-reference/unityengine/particlesystem/stop.md), [ParticleSystem.Pause](/engine/6000.0/script-reference/unityengine/particlesystem/pause.md), [ParticleSystem.isEmitting](/engine/6000.0/script-reference/unityengine/particlesystem/isemitting.md) functions.

The following example creates a GUI window for manipulating a Particle System.

### Examples

```csharp
using UnityEngine;

public class ParticleSystemControllerWindow : MonoBehaviour
{
    ParticleSystem system
    {
        get
        {
            if (_CachedSystem == null)
                _CachedSystem = GetComponent<ParticleSystem>();
            return _CachedSystem;
        }
    }
    private ParticleSystem _CachedSystem;

    public Rect windowRect = new Rect(0, 0, 300, 120);

    public bool includeChildren = true;

    void OnGUI()
    {
        windowRect = GUI.Window("ParticleController".GetHashCode(), windowRect, DrawWindowContents, system.name);
    }

    void DrawWindowContents(int windowId)
    {
        if (system)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Toggle(system.isPlaying, "Playing");
            GUILayout.Toggle(system.isEmitting, "Emitting");
            GUILayout.Toggle(system.isPaused, "Paused");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Play"))
                system.Play(includeChildren);
            if (GUILayout.Button("Pause"))
                system.Pause(includeChildren);
            if (GUILayout.Button("Stop Emitting"))
                system.Stop(includeChildren, ParticleSystemStopBehavior.StopEmitting);
            if (GUILayout.Button("Stop & Clear"))
                system.Stop(includeChildren, ParticleSystemStopBehavior.StopEmittingAndClear);
            GUILayout.EndHorizontal();

            includeChildren = GUILayout.Toggle(includeChildren, "Include Children");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Time(" + system.time + ")");
            GUILayout.Label("Particle Count(" + system.particleCount + ")");
            GUILayout.EndHorizontal();
        }
        else
            GUILayout.Label("No Particle System found");

        GUI.DragWindow();
    }
}
```

## Play()

Starts the Particle System.

```csharp
public void Play()
```

### Remarks

Sets the Particle Systems into play mode and enables emitting (if it has been disabled).

If the Particle System has been **paused**, then this resumes playing from the previous time.

If the Particle System has **stopped**, then the system starts from time 0, and, if it is relevant, the [ParticleSystem.startDelay](/engine/6000.0/script-reference/unityengine/particlesystem/startdelay.md) is applied. If the Particle System is **already playing**, the system continues to play and this function has no effect.

**Note**: Unity does not apply [ParticleSystem.MainModule.prewarm](/engine/6000.0/script-reference/unityengine/particlesystem/mainmodule/prewarm.md) when the Particle System resumes from a paused state. To apply `prewarm` when the Particle System resumes, call [ParticleSystem.Clear](/engine/6000.0/script-reference/unityengine/particlesystem/clear.md) after [ParticleSystem.Stop](/engine/6000.0/script-reference/unityengine/particlesystem/stop.md).

**Note**: If you invoke this function again before the particle system has had time to spawn a particle, the particle system restarts its internal counters. This means that if you invoke this function continuously, a particle system with a low emission rate will never start to play.

Additional Resources: [ParticleSystem.Stop](/engine/6000.0/script-reference/unityengine/particlesystem/stop.md), [ParticleSystem.Pause](/engine/6000.0/script-reference/unityengine/particlesystem/pause.md), [ParticleSystem.isEmitting](/engine/6000.0/script-reference/unityengine/particlesystem/isemitting.md) functions.

The following example creates a GUI window for manipulating a Particle System.

### Examples

```csharp
using UnityEngine;

public class ParticleSystemControllerWindow : MonoBehaviour
{
    ParticleSystem system
    {
        get
        {
            if (_CachedSystem == null)
                _CachedSystem = GetComponent<ParticleSystem>();
            return _CachedSystem;
        }
    }
    private ParticleSystem _CachedSystem;

    public Rect windowRect = new Rect(0, 0, 300, 120);

    public bool includeChildren = true;

    void OnGUI()
    {
        windowRect = GUI.Window("ParticleController".GetHashCode(), windowRect, DrawWindowContents, system.name);
    }

    void DrawWindowContents(int windowId)
    {
        if (system)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Toggle(system.isPlaying, "Playing");
            GUILayout.Toggle(system.isEmitting, "Emitting");
            GUILayout.Toggle(system.isPaused, "Paused");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Play"))
                system.Play(includeChildren);
            if (GUILayout.Button("Pause"))
                system.Pause(includeChildren);
            if (GUILayout.Button("Stop Emitting"))
                system.Stop(includeChildren, ParticleSystemStopBehavior.StopEmitting);
            if (GUILayout.Button("Stop & Clear"))
                system.Stop(includeChildren, ParticleSystemStopBehavior.StopEmittingAndClear);
            GUILayout.EndHorizontal();

            includeChildren = GUILayout.Toggle(includeChildren, "Include Children");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Time(" + system.time + ")");
            GUILayout.Label("Particle Count(" + system.particleCount + ")");
            GUILayout.EndHorizontal();
        }
        else
            GUILayout.Label("No Particle System found");

        GUI.DragWindow();
    }
}
```
