Files
Continentis/Assets/OtherPlugins/Feel/MMTools/Accessories/MMParticles/MMDelayParticles.cs
SoulliesOfficial d09b58fd80 架构大更
2026-03-20 11:56:50 -04:00

48 lines
1.4 KiB
C#

using UnityEngine;
namespace MoreMountains.Tools
{
[ExecuteAlways]
/// <summary>
/// MM delay particles.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Particles/MM Delay Particles")]
public class MMDelayParticles : MonoBehaviour
{
[Header("Delay")]
/// the duration of the delay, in seconds
public float Delay;
/// if this is true, this will delay by the same amount all children particle systems of this object
public bool DelayChildren = true;
/// if this is true, the delay will be applied on Start
public bool ApplyDelayOnStart;
[MMInspectorButtonAttribute("ApplyDelay")]
public bool ApplyDelayButton;
protected Component[] particleSystems;
protected virtual void Start()
{
if (ApplyDelayOnStart) ApplyDelay();
}
protected virtual void ApplyDelay()
{
if (gameObject.GetComponent<ParticleSystem>() != null)
{
var main = gameObject.GetComponent<ParticleSystem>().main;
main.startDelay = main.startDelay.constant + Delay;
}
particleSystems = GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem system in particleSystems)
{
var main = system.main;
main.startDelay = main.startDelay.constant + Delay;
}
}
}
}