简体   繁体   English

等待 unityEvent 完成

[英]Wait for unityEvent to finish

I am trying to use UnityEvent and wanted to use them for my movement script.我正在尝试使用 UnityEvent 并希望将它们用于我的运动脚本。 Here is a part of what I have:这是我所拥有的一部分:

if(movementEnabled){
   BeforeMovement.Invoke();
   transform.localPosition = upcommingLocalPosition;
   OnMovement.Invoke();
}

My problem here is that I would need the UnityEvent "BeforeMovenent" to end before continuing to the next line, so to make sure all method in it have completed their task before moving.我的问题是,在继续下一行之前,我需要 UnityEvent "BeforeMovenent" 结束,因此要确保其中的所有方法在移动之前都已完成其任务。

In short, I am looking for something similar to a Wait() method.简而言之,我正在寻找类似于 Wait() 方法的东西。

Is there any way I can achieve this using UnityEvent?有什么办法可以使用 UnityEvent 实现这一点吗?

UnityEvents 是同步的,所以只要你的事件监听器没有做任何异步的事情,你应该没问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM