0
所以我有一个Unity协程的方法,其中我有一些对象。这些对象表示正在从某个服务器收集的值,并且它们在准备就绪时发送一个Updated
事件。等待Unity协程中的事件?
我想知道什么最好的方法是等待所有的值被更新,在Unity的协同程序中。
public IEnumerator DoStuff()
{
foreach(var val in _updateableValues)
{
if (val.Value != null) continue;
else **wait for val.Updated to be fired then continue**
}
//... here I do stuff with all the values
// I use the WWW class here, so that's why it's a coroutine
}
这样做的最好方法是什么?
谢谢!
啊是的,我有这样的事件。我在问题中谈到的var.Updated是一个在更新值时触发的事件。我希望会有类似'yield return new WaitForUpdateEventOf(myObject)'的东西。 –
你*可以钩住'Update'事件来设置一个标志为'true',在这个标志上你将等待你的旋转锁定**或**,尝试重新构造逻辑,例如处理'Update'上的所有内容。在什么情况下,这些更新发生在什么对象上,你究竟想要做什么? –