init
This commit is contained in:
commit
341a877b4a
2338 changed files with 1346408 additions and 0 deletions
33
Assets/Scripts/Particles/ParticleSystemAutoDestroy.cs
Normal file
33
Assets/Scripts/Particles/ParticleSystemAutoDestroy.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public enum DisablingAction
|
||||
{
|
||||
Destroy, Deactivate
|
||||
}
|
||||
|
||||
public class ParticleSystemAutoDestroy : MonoBehaviour
|
||||
{
|
||||
public DisablingAction action = DisablingAction.Deactivate;
|
||||
private ParticleSystem ps;
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
ps = GetComponent<ParticleSystem>();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (ps)
|
||||
{
|
||||
if (!ps.IsAlive())
|
||||
{
|
||||
if (action == DisablingAction.Deactivate)
|
||||
gameObject.SetActive(false);
|
||||
else
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue