安装EmmyLUA插件
或者在github中下载
https://github.com/EmmyLua/VSCode-EmmyLua
https://github.com/jiehuali/VSCode-EmmyLua.git
增加调试Launch.json
打开文件夹后会变成create a launcher.json,点击Run And Debug, 选择EmmyLua New Debugger(这个是作者推荐的,更稳定些,前面两个已经不更新了)
- .vscode\launch.json
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387// https://blog.csdn.net/qq_34035956/article/details/109255357"version": "0.2.0","configurations": [{"type": "emmylua_new","request": "launch","name": "EmmyLua New Debug","host": "localhost","port": 9966,"ext": [".lua",".lua.txt",".lua.bytes"],// "ideConnectDebugger"改为false(这里ide是指VSCode,Debugger是指Unity"ideConnectDebugger": false}]
}
项目中加载EmmyLua
function luamain()-- 全局设置随机数math.randomseed(GetCurTime())openLuaDebugServer()...
end-- 开启LUA调试
function openLuaDebugServer()-- local openDebugLua = trueif openDebugLua thenconnectEmmyLua('localhost', '0.5.14')end
endfunction connectEmmyLua(addr, ver) -- connect EmmyLua-- package.cpath = package.cpath .. ';C:/Users/lijh/.vscode/extensions/tangzx.emmylua-0.5.14/debugger/emmy/windows/x86/?.dll'-- package.cpath = package.cpath .. ';'..os.getenv("USERPROFILE")..'/.vscode/extensions/tangzx.emmylua-0.5.14/debugger/emmy/windows/x86/?.dll'package.cpath = package.cpath .. ';'..os.getenv("USERPROFILE")..'/.vscode/extensions/tangzx.emmylua-'..ver..'/debugger/emmy/windows/x86/?.dll'local dbg = require ('emmy_core')dbg.tcpConnect(addr, 9966)
end
参考链接
- ( https://blog.csdn.net/qq_34035956/article/details/109255357 )
- ( https://www.cnblogs.com/sailJs/p/16435038.html )