Last active
February 11, 2018 08:36
-
-
Save tsubaki/6381213ad08eff7ffcb4 to your computer and use it in GitHub Desktop.
パーティクル再生終了後、オブジェクトを非アクティブへ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
再利用を前提とするため、OnEnable時にコルーチンを起動。コルーチンの停止処理はGameObjectにお任せする