mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 12:33:02 +00:00
30 lines
571 B
C#
30 lines
571 B
C#
using System.Collections;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace SanAndreasUnity.Utilities
|
|
{
|
|
|
|
public class DestroyWhenParticleSystemsFinish : MonoBehaviour
|
|
{
|
|
|
|
IEnumerator Start()
|
|
{
|
|
var systems = this.GetComponentsInChildren<ParticleSystem>();
|
|
|
|
while (true)
|
|
{
|
|
yield return null;
|
|
|
|
if (systems.All(s => !s.isPlaying))
|
|
{
|
|
Object.Destroy(this.gameObject);
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|