为什么"yield return new WaitForEndOfFrame()"永远不会在batchmode中返回?

ilk*_*las 7 testing integration-testing unity-game-engine

我正在尝试使用统一测试工具包编写集成测试.

测试中的测试运行没有问题(在播放模式下).

但是当我尝试从命令行运行集成测试时(在batchmode中),WaitForEndOfFrame协同程序永远不会返回.

这是一个已知问题还是我错过了什么?

我使用以下命令来运行测试:

 /Applications/Unity-5.3.1-f1/Unity.app/Contents/MacOS/Unity \
  -batchmode \
  -nographics \
  -logfile \
  -projectPath $(pwd) \
  -executeMethod UnityTest.Batch.RunIntegrationTests \
  -testscenes=TestScene \
  -resultsFileDirectory=$(pwd)
Run Code Online (Sandbox Code Playgroud)

Aiz*_*zen -3

如果您使用 C#,它将无法工作。如果你用JS就可以了。对于 C#,您需要使用 Coroutine、IEnumerable 来实现此目的。

与 Time WaitForSeconds 等的 Yielding 调用相同。它们不支持 C# 的 Yielding,因为 Mono Unity3d 只在 MainThread 上运行,不能让出,因为你会得到 App is not Responding。另一方面,当 JS 工作时,它并不是完全停止调用,而是停止自己的脚本。这就是为什么C#添加了invoke方法来实现延迟。