mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 20:43:04 +00:00
31 lines
571 B
C#
31 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;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|