|
我们的做法比较简单:
/// <summary>
/// 缩放粒子
/// </summary>
/// <param name=&#34;gameObj&#34;>粒子节点</param>
/// <param name=&#34;scale&#34;>绽放系数</param>
public static void ScaleParticleSystem(GameObject gameObj, float scale)
{
var hasParticleObj = false;
var particles = gameObj.GetComponentsInChildren<ParticleSystem>(true);
var max = particles.Length;
for (int idx = 0; idx < max; idx++)
{
var particle = particles[idx];
if(particle==null) continue;
hasParticleObj = true;
particle.startSize *= scale;
particle.startSpeed *= scale;
particle.startRotation *= scale;
particle.transform.localScale *= scale;
}
if (hasParticleObj)
{
gameObj.transform.localScale = new Vector3(scale, scale, 1);
}
} |
|