39 lines
600 B
C#
39 lines
600 B
C#
using UnityEngine;
|
|
using OHM.UnityToolkit.Pooling;
|
|
|
|
namespace OHM.UnityToolkit
|
|
{
|
|
public class DelayedDestroy : MonoBehaviour, PooledObjectListener
|
|
{
|
|
public float delay;
|
|
|
|
public bool unscaledTime;
|
|
|
|
private float _remainingDelay;
|
|
|
|
public void OnRelease()
|
|
{
|
|
}
|
|
|
|
public void OnReset()
|
|
{
|
|
_remainingDelay = delay;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
_remainingDelay = delay;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_remainingDelay -= (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
|
if (_remainingDelay <= 0f)
|
|
{
|
|
PoolsManager.ReleaseObject(base.gameObject);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|