public void Play (bool withChildren= true);

参数

withChildren同时播放所有子粒子系统。

描述

启动粒子系统。

将粒子系统设置为播放模式并启用发射(如果已禁用)。

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 is applied.

另请参阅:StopPauseisEmitting 函数。

下面的示例将创建一个用于操作粒子系统的 GUI 窗口。

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 &amp; 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(); } }