Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The code of lua calling C # method under the framework of Luaframework

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the code of lua calling C # method under Luaframework framework". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn the code for lua to call the C# method under the Luaframework framework.

Framework introduction

This project uses luaframework+ugui, consult du Niang for details.

Create a C# class

First, write a C # script. The method in this script is what we need to call in lua. The method we need to call here is named ShirlnDebug.

Using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShirlnManager {public void ShirlnDebug () {UnityEngine.Debug.Log ("ShirlnManager = Debug");}} C# class is registered to the lua type list

Add the C# type to CustomSettings and register it with the lua's type list as follows:

Clear the warp file

Back to the project to perform the following operations, the successful implementation will pop up a confirmation box, click OK on the ok1, this step is equivalent to deleting the warp file, and then generating a new warp file.

The following code is automatically added after success

And generate warp files in the corresponding directory

Lua calls C #

So much work has been done before, in fact, it is all preparatory work, and now that the preparatory work is completed, it will be called normally. It's that simple!

The calling method is as follows:

ShirlnInstant = ShirlnManager.New () ShirlnInstant:ShirlnDebug () so far, I believe you have a deeper understanding of "the code that lua calls the C# method under the Luaframework framework". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report