Delayed Actions - Hertzole/HertzLib GitHub Wiki

Delayed Actions

Delayed Actions is a singleton script and thread safe way to create delayed actions using only Unity's own Update. No coroutines, no threads or anything! It even hooks into the Update Manager if it's present.

All the actions run in parallel, so no action needs to be completed before one another.

How to use

It's pretty simple to use as it's a static class with only one important method.

using Hertzole.HertzLib;
using UnityEngine;

public class ActionsToBeDelayed : MonoBehaviour
{
	private void Start()
	{
		DelayedActions.ScheduleAction(() =>
		{
			Debug.Log("Create actions on the fly like this!");
		}, 2);
		
		DelayedActions.ScheduleAction(DelayedFunction, 5);
	}
	
	private void DelayedFunction()
	{
		Debug.Log("Hello world... after 5 seconds of wait!");
	}
}

You schedule the Action and the time (a float).