31 lines
696 B
C#
31 lines
696 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TriggerParticleSystemOnce : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject particleGO;
|
|
private ParticleSystem particles;
|
|
|
|
private void Awake()
|
|
{
|
|
particles = particleGO.GetComponent<ParticleSystem>();
|
|
particles.Stop();
|
|
particleGO.SetActive(false);
|
|
}
|
|
|
|
public void PlayOnce()
|
|
{
|
|
particleGO.SetActive(true);
|
|
particles.Play();
|
|
StartCoroutine(DisableParticleOnStopped());
|
|
}
|
|
|
|
IEnumerator DisableParticleOnStopped()
|
|
{
|
|
while (particles.isPlaying) yield return null;
|
|
|
|
particleGO.SetActive(false);
|
|
}
|
|
}
|