MIF_E31221325/Assets/Sprites/Space Shooter Template FREE/Scripts/VisualEffect.cs

24 lines
683 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This script attaches to VisualEffect objects. It destroys or deactivates them after the defined time.
/// </summary>
public class VisualEffect : MonoBehaviour {
[Tooltip("the time after object will be destroyed")]
public float destructionTime;
private void OnEnable()
{
StartCoroutine(Destruction()); //launching the timer of destruction
}
IEnumerator Destruction() //wait for the estimated time, and destroying or deactivating the object
{
yield return new WaitForSeconds(destructionTime);
Destroy(gameObject);
}
}