callback

What about the callback in Unigine?

Any function from system, world or editor scripts can be called in a C++ code. UnigineScript functions that are called from an external code are known as callbacks. Via callbacks scripts can communicate with each other, as well as with the external application.

The sequence of function call will be as follows:

  1. The interpreter exports the runWorldFunction() function to make it available from the script.
  2. The engine is initialized, and the init() function of the script is called. This function calls the exported runWorldFunction() function.
  3. The exported runWorldFunction() function calls the callback() function from the script.
  4. The engine enters the main loop, where it calls the counter() function from the script by using the Unigine::Engine::runWorldFunction() function

在脚本中函数的调用顺序是,先调用init()函数,然后调用exportecd function runWorldFunction(),因为runWorldFunction()中调用了脚本中的函数callback(),所以runWorldFunction()会先调用callback(),也就是说在脚本中会先执行callback().

原文地址:https://www.cnblogs.com/wzheng/p/3893401.html