Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active February 11, 2018 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/6381213ad08eff7ffcb4 to your computer and use it in GitHub Desktop.
Save tsubaki/6381213ad08eff7ffcb4 to your computer and use it in GitHub Desktop.
パーティクル再生終了後、オブジェクトを非アクティブへ
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

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

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