VsCode使用EmmyLua插件调试Unity工程Lua代码的详细步骤
作者:Cuijiahao 时间:2022-12-25 14:13:25
一、VSCode安装EmmyLua
二、添加配置文件
三、设置配置文件
执行完第二步会弹出添加好的launch.json配置文件,这个文件只需要修改“ideConnectDebugger” = false,其他一般不用修改。
四、添加Lua断点调试入口
luaEnv变量必须为全局唯一
路径标红的地方配上你的正确路径名
var path = "C:/Users/你的用户名/.vscode/extensions/tangzx.emmylua-0.5.7/debugger/emmy/windows/x64/emmy_core.dll";
private void Awake()
{
luaEnv = new LuaEnv();
#if UNITY_EDITOR_WIN
//链接rider和vscode的lua调试器
var path = "C:/Users/你的用户名/.vscode/extensions/tangzx.emmylua-0.5.7/debugger/emmy/windows/x64/emmy_core.dll";
if (File.Exists(path))
{
path = path.Replace("emmy_core.dll", "?.dll");
bool openDebugFinish = true;
try
{
luaEnv.DoString(
string.Format("package.cpath = package.cpath .. ';{0}'", path) +
"local dbg = require('emmy_core')" +
"dbg.tcpConnect('localhost', 9966)"
);
}
catch (Exception e)
{
openDebugFinish = false;
Debug.LogError("不需要调试请忽略>>>>>\t调试server未能连接:\n" + e.Message);
}
finally
{
if (openDebugFinish)
{
Debug.LogError("成功连接调试server\n" + path);
}
}
}
#endif
m_LuaScripts = new Dictionary<string, byte[]>();
}
五、运行unity测试断点功能
首先要确保Lua入口的断点调试代码为true,然后按下F5开启断点调试模式,再运行Unity,否则会报错,这个顺序不能错。连接成功后,VSCode的控制台会看到以下信息,就证明是断点调试开启了
来源:https://blog.csdn.net/cuijiahao/article/details/126282454
标签:VsCode,EmmyLua,Lua
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
HashMap在JDK7与JDK8中的实现过程解析
2022-03-04 18:26:44
![](https://img.aspxhome.com/file/2023/7/132117_0s.png)
Java动态 代理的应用详解
2023-11-25 08:15:24
合成聚合复用原则_动力节点Java学院整理
2023-06-27 22:05:20
![](https://img.aspxhome.com/file/2023/9/57599_0s.png)
深入浅析SpringBoot中的自动装配
2021-08-21 17:45:11
Java高并发BlockingQueue重要的实现类详解
2021-06-20 12:08:24
解决RestTemplate第一次请求响应速度较慢的问题
2021-10-20 15:50:50
Android处理图像数据转换的各种方法
2023-07-10 10:58:50
Android开发文件存储实例
2021-10-13 17:27:01
![](https://img.aspxhome.com/file/2023/8/96788_0s.jpg)
解析JavaSE的继承和多态
2023-11-24 16:13:48
mybatis批量添加,批量更新之前如何判断是否已经存在
2022-01-03 20:33:38
![](https://img.aspxhome.com/file/2023/2/78962_0s.jpg)
Gradle:修改默认的Build配置文件名方式
2023-11-28 20:18:01
![](https://img.aspxhome.com/file/2023/7/60617_0s.png)
SpringBoot整合mybatis的方法详解
2023-09-02 06:23:57
![](https://img.aspxhome.com/file/2023/5/58455_0s.png)
Android Service中使用Toast无法正常显示问题的解决方法
2022-01-23 08:38:12
![](https://img.aspxhome.com/file/2023/7/125537_0s.jpg)
简单的观察者模式示例分享
2023-02-11 12:52:12
Android无需读写权限通过临时授权读写用户文件详解
2022-11-05 12:50:54
![](https://img.aspxhome.com/file/2023/1/137751_0s.png)
Java聊天室之使用Socket实现传递对象
2023-02-07 15:28:52
![](https://img.aspxhome.com/file/2023/7/68557_0s.png)
feignclient https 接口调用报证书错误的解决方案
2021-08-20 18:35:55
![](https://img.aspxhome.com/file/2023/8/66518_0s.jpg)
Android 7.0应用之间如何共享文件
2021-09-18 08:43:15
mybatis foreach 循环 list(map)实例
2023-11-23 23:39:05
![](https://img.aspxhome.com/file/2023/6/58876_0s.jpg)
JAVA反射机制实例详解
2021-11-08 13:39:34