Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active Feb 11, 2018
Embed
What would you like to do?
パーティクル再生終了後、オブジェクトを非アクティブへ
using UnityEngine;
using System.Collections;
public class DisableParticle : MonoBehaviour
{
void OnEnable()
{
StartCoroutine (ParticleWorking ());
}
IEnumerator ParticleWorking()
{
var particle = GetComponent<ParticleSystem> ();
yield return new WaitWhile (() => particle.IsAlive (true));
gameObject.SetActive (false);
}
}
@tsubaki
Copy link
Author

tsubaki commented Mar 2, 2016

再利用を前提とするため、OnEnable時にコルーチンを起動。コルーチンの停止処理はGameObjectにお任せする

@lovelyappleHoge
Copy link

lovelyappleHoge commented Feb 11, 2018

これでしたか!
ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment