mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 09:08:23 -05:00
29 lines
558 B
C#
29 lines
558 B
C#
using UnityEngine;
|
|
using UnityEngine.Assertions;
|
|
using UnityAtoms.BaseAtoms;
|
|
|
|
public class DestroyMe : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
FloatReference _delay = new FloatReference(-1f);
|
|
|
|
void Start()
|
|
{
|
|
Assert.IsNotNull(_delay);
|
|
if (_delay.Value >= 0f)
|
|
{
|
|
Destroy(gameObject, _delay.Value);
|
|
}
|
|
}
|
|
|
|
public void DestroyImmediate() => Destroy(gameObject);
|
|
|
|
public void DestroyIfZeroOfBelow(int value)
|
|
{
|
|
if (value <= 0)
|
|
{
|
|
DestroyImmediate();
|
|
}
|
|
}
|
|
}
|