using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//设置一个可序列化类
[Serializable]
public class DelaySystem
{
public GameObject rootNode;
public float delay;
}
public class TestParticleDelay : MonoBehaviour {
//定义需要被delay的gameobject和时间
public DelaySystem[] delaySystem;
#if UNITY_EDITOR
[ContextMenu("Auto Set Particle Delay")]
private void SetDelay()
{
for (int i = 0; i < delaySystem.Length; i++)
{
GameObject rootNode = delaySystem[i].rootNode;
float delay = delaySystem[i].delay;
ParticleSystem[] ps = rootNode.GetComponentsInChildren<ParticleSystem>();
for (int j = 0; j < ps.Length; j++)
{
var main = ps[j].main;
main.startDelay = delay;
}
}
}
#endif
}
1、拖选对应particle组,并设置delay时间
2、右键TestParticleDelay,选择AutoSetParticleDelay,即可按需求批量设置