Is it possible to write myself WaitForXXX classes, use in coroutine to wait for events not provided by unity?
Any examples?
WaitForSeconds would be implemented like this:
function MyWaitForSeconds (waitTime : float) {
var timer = 0.0;
while (timer <= waitTime) {
yield;
timer += Time.deltaTime;
}
}
Obviously there’s no point actually using that since WaitForSeconds exists, but you can use that as a template and modify it for whatever you need.
–Eric
Thx, simple but not an efficient design, though,especially when massive WaitForXXXs are pending.I thought it was an event-based way previously.
And what about the class form? In c#, I must write
yield return new WaitForSeconds(1.0);
WaitForSeconds is a class that inherits from YieldInstruction. Can I write a class implements YieldInstruction?
More info on this topic can be found here:
http://forum.unity3d.com/threads/10570-Creating-our-own-YieldInstructions…
Hi Cometeor,
Please look at Coroutine Manager on the asset store. It is open source so you can easily add your own WaitForXXX. See that CoroutineManager.WaitForSeconds() is provided as an example.
As I am continuously trying to improve Coroutine Manager, please let me know what features you need.
Hope this helps.