Files
BeatSaber/Assets/VRBeatsKit/Scripts/Other/DestroyOnBecameInvisible.cs
T

27 lines
455 B
C#
Raw Normal View History

using UnityEngine;
namespace VRBeats
{
public class DestroyOnBecameInvisible : MonoBehaviour
{
private float maxLifeTime = 10.0f;
private float timer = 0.0f;
private void Update()
{
timer += Time.deltaTime;
if (timer >= maxLifeTime)
Destroy(gameObject);
}
private void OnBecameInvisible()
{
Destroy(gameObject);
}
}
}