# Play

> Starts the Particle System and resets its playback time to 0.

## Definition

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

## Play(bool)

Starts the Particle System and resets its playback time to 0.

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

### Parameters

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

### Remarks

The Play() function switches the Particle System into play mode and enables particle emission (if it was previously disabled). The exact behavior varies based on the system's current state:

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 [\_startDelay](/engine/6000.7/script-reference/unityengine/particlesystem/mainmodule/startdelay.md) is applied.

If the Particle System is **already playing**, the system continues to play and reset the playback time to 0. For looping systems, the reset may have no visible impact. However, for non-looping systems, particles may start to emit again, depending on the system’s configuration.

For scripted control of Particle System playback, such as responding to game events or user input, `Play()` is the method used to initiate or restart particle emission. You can achieve more comprehensive control by using `Play()` in combination with methods like [ParticleSystem.Pause](/engine/6000.7/script-reference/unityengine/particlesystem/pause.md) and [ParticleSystem.Stop](/engine/6000.7/script-reference/unityengine/particlesystem/stop.md), and by monitoring properties such as time and [\_particleCount](/engine/6000.7/script-reference/unityengine/particlesystem/particlecount.md).

**Note**: Unity does not apply [\_prewarm](/engine/6000.7/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.7/script-reference/unityengine/particlesystem/clear.md) after [ParticleSystem.Stop](/engine/6000.7/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.7/script-reference/unityengine/particlesystem/stop.md), [ParticleSystem.Pause](/engine/6000.7/script-reference/unityengine/particlesystem/pause.md), [\_isEmitting](/engine/6000.7/script-reference/unityengine/particlesystem/isemitting.md)

### Examples

```csharp
using UnityEngine;

public class SimpleParticleSystemController : MonoBehaviour
{
    [SerializeField] private ParticleSystem particleSystem;

    void Update()
    {
        // Press the spacebar to restart the Particle System.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            particleSystem.Play();
            Debug.Log("Particle System restarted. Playback time reset to 0.");
        }
    }
}
```

```csharp
using UnityEngine;

 //The window allows you to play, pause, or stop the system, toggle child system inclusion, and view information like playback time and particle count.
public class ParticleSystemControllerWindow : MonoBehaviour
{
    ParticleSystem m_ParticleSystem;
    Rect m_WindowRect = new Rect(0, 0, 300, 120);
    bool m_IncludeChildren = true;

    void Start()
    {
        m_ParticleSystem = GetComponent<ParticleSystem>();
    }

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

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

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

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

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

        GUI.DragWindow();
    }
}
```

## Play()

Starts the Particle System and resets its playback time to 0.

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

### Remarks

The Play() function switches the Particle System into play mode and enables particle emission (if it was previously disabled). The exact behavior varies based on the system's current state:

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 [\_startDelay](/engine/6000.7/script-reference/unityengine/particlesystem/mainmodule/startdelay.md) is applied.

If the Particle System is **already playing**, the system continues to play and reset the playback time to 0. For looping systems, the reset may have no visible impact. However, for non-looping systems, particles may start to emit again, depending on the system’s configuration.

For scripted control of Particle System playback, such as responding to game events or user input, `Play()` is the method used to initiate or restart particle emission. You can achieve more comprehensive control by using `Play()` in combination with methods like [ParticleSystem.Pause](/engine/6000.7/script-reference/unityengine/particlesystem/pause.md) and [ParticleSystem.Stop](/engine/6000.7/script-reference/unityengine/particlesystem/stop.md), and by monitoring properties such as time and [\_particleCount](/engine/6000.7/script-reference/unityengine/particlesystem/particlecount.md).

**Note**: Unity does not apply [\_prewarm](/engine/6000.7/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.7/script-reference/unityengine/particlesystem/clear.md) after [ParticleSystem.Stop](/engine/6000.7/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.7/script-reference/unityengine/particlesystem/stop.md), [ParticleSystem.Pause](/engine/6000.7/script-reference/unityengine/particlesystem/pause.md), [\_isEmitting](/engine/6000.7/script-reference/unityengine/particlesystem/isemitting.md)

### Examples

```csharp
using UnityEngine;

public class SimpleParticleSystemController : MonoBehaviour
{
    [SerializeField] private ParticleSystem particleSystem;

    void Update()
    {
        // Press the spacebar to restart the Particle System.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            particleSystem.Play();
            Debug.Log("Particle System restarted. Playback time reset to 0.");
        }
    }
}
```

```csharp
using UnityEngine;

 //The window allows you to play, pause, or stop the system, toggle child system inclusion, and view information like playback time and particle count.
public class ParticleSystemControllerWindow : MonoBehaviour
{
    ParticleSystem m_ParticleSystem;
    Rect m_WindowRect = new Rect(0, 0, 300, 120);
    bool m_IncludeChildren = true;

    void Start()
    {
        m_ParticleSystem = GetComponent<ParticleSystem>();
    }

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

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

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

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

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

        GUI.DragWindow();
    }
}
```
