Unity之Luaframework框架lua调用C#方法
作者:爱上游戏开发 时间:2022-02-14 11:22:26
前言
最近,新来的同事写接口,需要知道lua怎么调用C#脚本,趁这个机会也给大家分享一下。道理我也不多少,直接上干货。
框架介绍
本项目采用luaframework+ugui,详情咨询度娘。
框架:
创建C#类
首先写个C#脚本,这个脚本里的方法是我们需要在lua中调用的,这里需要调用的方法命名为ShirlnDebug
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShirlnManager
{
public void ShirlnDebug()
{
UnityEngine.Debug.Log("ShirlnManager ====Debug");
}
}
C#类注册到lua类型列表
在CustomSettings中添加C#类型,将其注册到lua的类型列表,方法如下:
清除warp文件
回到工程执行下列操作,执行成功后会弹出一个确认框,点击确认就ok1了,这步相当于先删除warp文件,再生成新的warp文件。
成功后会自动添加下列代码
并且在对应目录生成warp文件
lua调用C#
前面做了这么多工作,其实都是准备工作,准备工作既然完成了,接下来,就是正常的调用了。就是这么简单!
调用方法如下:
ShirlnInstant = ShirlnManager.New()
ShirlnInstant:ShirlnDebug()
来源:https://blog.csdn.net/shirln/article/details/120044625
标签:Unity,Luaframework,框架
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
mybatis-plus自动填充插入更新时间有8小时时差
2021-07-26 07:18:40
![](https://img.aspxhome.com/file/2023/7/74767_0s.png)
SpringBoot详细讲解异步任务如何获取HttpServletRequest
2023-01-04 18:01:09
基于Java实现收发电子邮件功能
2021-08-23 17:30:14
![](https://img.aspxhome.com/file/2023/7/80307_0s.png)
Java栈之链式栈存储结构的实现代码
2022-01-18 09:38:48
Spring Cloud 整合 nacos实现动态配置中心的详细步骤
2023-01-19 18:15:00
![](https://img.aspxhome.com/file/2023/3/77493_0s.jpg)
Struts2中异常处理机制分析
2023-11-17 21:54:32
Java快速掌握Vector类方法
2023-11-24 22:49:18
![](https://img.aspxhome.com/file/2023/1/60241_0s.png)
Java8新特性之默认方法(default)浅析
2023-10-03 10:41:13
![](https://img.aspxhome.com/file/2023/1/62051_0s.png)
浅析c# 线程同步
2022-09-19 18:43:03
SpringCloud Hystrix-Dashboard仪表盘的实现
2023-03-16 18:38:03
![](https://img.aspxhome.com/file/2023/3/80973_0s.png)
springboot访问template下的html页面的实现配置
2023-02-09 23:33:21
![](https://img.aspxhome.com/file/2023/5/61085_0s.png)
C#正则表达式分解和转换IP地址实例(C#正则表达式大全 c#正则表达式语法)
2023-07-17 07:11:25
Java设计模式七大原则之里氏替换原则详解
2022-05-22 13:41:10
![](https://img.aspxhome.com/file/2023/8/61868_0s.jpg)
java解析json数组方式
2023-08-10 17:22:14
![](https://img.aspxhome.com/file/2023/8/58188_0s.png)
基于Spring Boot保护Web应用程序
2022-11-15 19:14:48
Java基础之重载(Overload)与重写(Override)详解
2023-07-31 08:10:25
Springboot实现给前端返回一个tree结构方法
2022-04-02 23:37:07
![](https://img.aspxhome.com/file/2023/9/84699_0s.png)
详解AndroidStudio JNI +Gradle3.0以上JNI爬坑之旅
2021-09-01 05:45:04
![](https://img.aspxhome.com/file/2023/2/88102_0s.jpg)
hibernate-validator改进校验框架validator v0.4使用
2023-01-22 21:08:07
WPF TextBox和PasswordBox添加水印
2021-09-30 16:06:02
![](https://img.aspxhome.com/file/2023/6/78156_0s.jpg)