29 lines
558 B
C#
Raw Normal View History

2020-03-05 00:48:39 +01:00
using UnityEngine;
using UnityEngine.Assertions;
using UnityAtoms.BaseAtoms;
public class DestroyMe : MonoBehaviour
{
[SerializeField]
2020-03-11 21:11:27 +01:00
FloatReference _delay = new FloatReference(-1f);
2020-03-05 00:48:39 +01:00
void Start()
{
Assert.IsNotNull(_delay);
2020-03-11 21:11:27 +01:00
if (_delay.Value >= 0f)
{
Destroy(gameObject, _delay.Value);
}
2020-03-05 00:48:39 +01:00
}
2020-03-15 23:18:29 +01:00
public void DestroyImmediate() => Destroy(gameObject);
public void DestroyIfZeroOfBelow(int value)
2020-03-05 00:48:39 +01:00
{
2020-03-15 23:18:29 +01:00
if (value <= 0)
{
DestroyImmediate();
}
2020-03-05 00:48:39 +01:00
}
}