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