Skip to content

DelayedCall

Jan-Ole Schümann edited this page May 21, 2017 · 5 revisions

Static Method DelayedCall

DC DelayedCall(float delay, Action callback) DC DelayedCall(float delay, Action callback, object pars)

DelayedCall allows to call a method after a certain delay. It can be used both with and without an argument that is passed to the method. DelayedCall returns a DC object which allows to terminate the delayed call using the Kill() method of the DC object.

Example

In this example, the method onDelay is called after 2 seconds with a GameObject passed as a parameter.

void Start ()
{
	GameObject gameObject = GameObject.Find("name_of_gameobject").gameObject;
	Action<object> onDelay = this.onDelay;
	TweenSharp.DelayedCall(2f, onDelay, gameObject);
}

private void onDelay(object obj)
{
	Debug.Log("Name: " + (obj as GameObject).name);
}
Clone this wiki locally