Skip to main content

DestroyByTime

A class in Root.Township, the global namespace.

A pooled object that releases itself back to its pool a set time after it is requested. Used for short-lived effects.

Constructors​

MemberWhat it is
DestroyByTime()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

2 private and internal fields
MemberWhat it is
private AltaCoroutine destroyCoroutineThe running countdown, restarted each time the object is taken from the pool.
private float timeBacking field for Time: seconds until release.

Properties​

MemberWhat it is
float Time { get; set; }Seconds before release. Setting it restarts the timer.

Methods​

MemberWhat it is
override void Release()Returns the object to the pool if not already released.
override void ResetRun()Resets the object and restarts the timer.
protected virtual void Awake()Starts the timer each time the object is taken from the pool.
protected virtual IEnumerator Destroy() (iterator)Coroutine that waits Time seconds then releases the object.
protected void StartRuning(PooledObject pooledObject)Restarts the release timer.