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.
37 lines
854 B
37 lines
854 B
4 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
[RequireComponent(typeof(ParticleSystem))]
|
||
|
public class CFX_AutoDestructShuriken : MonoBehaviour
|
||
|
{
|
||
|
public bool OnlyDeactivate;
|
||
|
|
||
|
void OnEnable()
|
||
|
{
|
||
|
StartCoroutine("CheckIfAlive");
|
||
|
}
|
||
|
|
||
|
IEnumerator CheckIfAlive()
|
||
|
{
|
||
|
while (true)
|
||
|
{
|
||
|
yield return new WaitForSeconds(0.5f);
|
||
|
if (!GetComponent<ParticleSystem>().IsAlive(true))
|
||
|
{
|
||
|
if (OnlyDeactivate)
|
||
|
{
|
||
|
#if UNITY_3_5
|
||
|
this.gameObject.SetActiveRecursively(false);
|
||
|
#else
|
||
|
this.gameObject.SetActive(false);
|
||
|
#endif
|
||
|
}
|
||
|
else
|
||
|
//GameObject.Destroy(this.gameObject);
|
||
|
EntitiesManager.Instance.DeleteObj(gameObject);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|