using UnityEngine; /// <summary> /// 粒子系统辅助类 /// </summary> public sealed class ParticleSystemHelper { // 获取对象上的所有粒子系统 public static ParticleSystem[] GetParticleSystem(Transform transform, bool includeInactive=true) { if (transform == null) return null; ParticleSystem[] psArr = transform.GetComponentsInChildren<ParticleSystem>(includeInactive); return psArr; } // 播放 public static void Play(Transform transform) { ParticleSystem[] psArr = GetParticleSystem(transform); if (psArr == null) return; foreach (var ps in psArr) ps.Play(); } // 停止 public static void Stop(Transform transform) { ParticleSystem[] psArr = GetParticleSystem(transform); if (psArr == null) return; foreach (var ps in psArr) ps.Stop(); } }