|
@@ -55,6 +55,12 @@ namespace KairoEngine.Core
|
|
callback();
|
|
callback();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Executes a function after a certain time has passed, based on Time.scale.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="time">In miliseconds</param>
|
|
|
|
+ /// <param name="action">A function to be executed</param>
|
|
|
|
+ /// <returns>A CompositeDisposable which can be used to cancel the timer</returns>
|
|
public static CompositeDisposable Execute(float time, Action action)
|
|
public static CompositeDisposable Execute(float time, Action action)
|
|
{
|
|
{
|
|
var timer = Observable.Timer(TimeSpan.FromMilliseconds(time));
|
|
var timer = Observable.Timer(TimeSpan.FromMilliseconds(time));
|
|
@@ -65,6 +71,23 @@ namespace KairoEngine.Core
|
|
}).AddTo(cancel);
|
|
}).AddTo(cancel);
|
|
return cancel;
|
|
return cancel;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Executes a function after a certain real time has passed.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="time">In miliseconds</param>
|
|
|
|
+ /// <param name="action">A function to be executed</param>
|
|
|
|
+ /// <returns>A CompositeDisposable which can be used to cancel the timer</returns>
|
|
|
|
+ public static CompositeDisposable ExecuteRealTime(float time, Action action)
|
|
|
|
+ {
|
|
|
|
+ var timer = Observable.Timer(TimeSpan.FromMilliseconds(time), Scheduler.MainThreadIgnoreTimeScale);
|
|
|
|
+ CompositeDisposable cancel = new CompositeDisposable();
|
|
|
|
+ timer.Subscribe(xs => {
|
|
|
|
+ action();
|
|
|
|
+ cancel.Dispose();
|
|
|
|
+ }).AddTo(cancel);
|
|
|
|
+ return cancel;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|