IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
DestroyOnParticleSystemDeath.cs
1 //======= Copyright (c) Valve Corporation, All rights reserved. ===============
2 //
3 // Purpose: Destroys this object when its particle system dies
4 //
5 //=============================================================================
6 
7 using UnityEngine;
8 using System.Collections;
9 
10 namespace Valve.VR.InteractionSystem
11 {
12  //-------------------------------------------------------------------------
13  [RequireComponent( typeof( ParticleSystem ) )]
14  public class DestroyOnParticleSystemDeath : MonoBehaviour
15  {
16  private ParticleSystem particles;
17 
18  //-------------------------------------------------
19  void Awake()
20  {
21  particles = GetComponent<ParticleSystem>();
22 
23  InvokeRepeating( "CheckParticleSystem", 0.1f, 0.1f );
24  }
25 
26 
27  //-------------------------------------------------
28  private void CheckParticleSystem()
29  {
30  if ( !particles.IsAlive() )
31  {
32  Destroy( this.gameObject );
33  }
34  }
35  }
36 }