CFX_AutodestructWhenNoChildren.cs 364 B

123456789101112131415161718
  1. using UnityEngine;
  2. using System.Collections;
  3. // Cartoon FX - (c) 2013, Jean Moreno
  4. // Automatically destroys the GameObject when there are no children left.
  5. public class CFX_AutodestructWhenNoChildren : MonoBehaviour
  6. {
  7. // Update is called once per frame
  8. void Update ()
  9. {
  10. if( transform.childCount == 0)
  11. {
  12. GameObject.Destroy(this.gameObject);
  13. }
  14. }
  15. }