ParticleSystemMultiplier.cs 792 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. namespace UnityStandardAssets.Effects
  4. {
  5. public class ParticleSystemMultiplier : MonoBehaviour
  6. {
  7. // a simple script to scale the size, speed and lifetime of a particle system
  8. public float multiplier = 1;
  9. private void Start()
  10. {
  11. var systems = GetComponentsInChildren<ParticleSystem>();
  12. foreach (ParticleSystem system in systems)
  13. {
  14. ParticleSystem.MainModule mainModule = system.main;
  15. mainModule.startSizeMultiplier *= multiplier;
  16. mainModule.startSpeedMultiplier *= multiplier;
  17. mainModule.startLifetimeMultiplier *= Mathf.Lerp(multiplier, 1, 0.5f);
  18. system.Clear();
  19. system.Play();
  20. }
  21. }
  22. }
  23. }