Objective
In my first article in this series, I mentioned the configuration and extensibility of the Lua script for hosting scripts. The call to an external LUA script in the previous section corresponds to the configuration of one of its two major features, so how does another feature work? That's what we're talking about today: the LUA function. The Ulua plugin is a solution to the Unity3d hot update, and the LUA function becomes critical when we need to make some local logical changes to the host program. So how do I call Lua functions in Ulua, now let's take a look! We'll look at two examples of how to call LUA functions.
A first example
First, the function of this example is very simple, so we write it as a string in the C # script, the detailed process has been very clearly commented out, as follows:
We mainly use the Luafunction class in Luainterface to deal with the relevant LUA functions. The function above is simple, mostly accepting arguments and outputting values. The results are as follows:
It is apparent that the return values in the arguments and LUA functions passed into the LUA function are actually reflected in the C # script and the calling function succeeds.
A second example
This example differs from the above, mainly by passing in multiple parameters. The Lua script is independent, and we read the standalone LUA script in the first way mentioned in the previous section, and some of what we said earlier is no longer in detail. The Lua script is as follows:
Then pass in the C # script the relevant parameters, and calculate, output the results, C # script is as follows:
The results are as follows:
Conclusion
Let's get here today. If there is any mistake, I would appreciate it if the great God can criticize it. If you like my article, please support a lot, more praise. Have any suggestions, welcome to visit my personal website (http://chunqiuyiyu.sinaapp.com/), we together learn progress. Goodbye to the next article!
Ulua Learning call Lua function (v)