-
Notifications
You must be signed in to change notification settings - Fork 1
DelayedCall
Jan-Ole Schümann edited this page Oct 6, 2018
·
5 revisions
DC DelayedCall(float delay, Action callback, bool useFrames = false)
DC DelayedCall(float delay, Action<object> callback, object pars, bool useFrames = false)
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. If useFrames is set to true, time is specified in frames instead of seconds.
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);
}