Ulua Learning call Lua function (v)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.