Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 1.27 KB

README.md

File metadata and controls

23 lines (14 loc) · 1.27 KB

DelayedActions for Unity

Simplified and debuggable alternative to Invoke, InvokeRepeating and Coroutines.

Installation

To add this to a Unity project:

Usage

In any script, use DelayedActions.Start(...) to start an action after the specified delay, optionally repeating. The function returns a DelayedAction object, which you can store to later check its state, change its properties or stop it before its (next) execution.

Another feature of this script enables you to run code that needs to run on the main Unity thread, from anywhere, by calling DelayedActions.NextUpdate(Action) or DelayedActions.NextFixedUpdate(Action). The provided Action will then be executed in the next Update or FixedUpdate by the Scheduler.

Destroy on scene load

By default, the Delayed Action Scheduler object that's created, will be persistent across Scene loads, meaning that any delayed actions started will still trigger after loading a new Scene. If you don't want this, set DelayedActions.DestroyOnLoad = true before starting your first DelayedAction.