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:
- The interpreter exports the runWorldFunction() function to make it available from the script.
- The engine is initialized, and the init() function of the script is called. This function calls the exported runWorldFunction() function.
- The exported runWorldFunction() function calls the callback() function from the script.
- 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().