You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
732 B

  1. using System;
  2. using UnityEngine;
  3. public class SpawnedParticles : MonoBehaviour
  4. {
  5. public virtual void Play()
  6. {
  7. int i = 0;
  8. int num = this._particleSystems.Length;
  9. while (i < num)
  10. {
  11. this._particleSystems[i].Play();
  12. i++;
  13. }
  14. UnityEngine.Object.Destroy(base.gameObject, this.GetLongestDuration());
  15. }
  16. private float GetLongestDuration()
  17. {
  18. float num = float.MinValue;
  19. int i = 0;
  20. int num2 = this._particleSystems.Length;
  21. while (i < num2)
  22. {
  23. ParticleSystem.MainModule main = this._particleSystems[i].main;
  24. num = Mathf.Max(num, main.duration + main.startLifetime.constantMax);
  25. i++;
  26. }
  27. return num;
  28. }
  29. [SerializeField]
  30. private ParticleSystem[] _particleSystems;
  31. }