一、VSCode安裝EmmyLua
?二、添加配置文件
三、設(shè)置配置文件
執(zhí)行完第二步會彈出添加好的launch.json配置文件,這個文件只需要修改“ideConnectDebugger” = false,其他一般不用修改。
?
?四、添加Lua斷點調(diào)試入口
luaEnv變量必須為全局唯一
路徑標(biāo)紅的地方配上你的正確路徑名
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調(diào)試器
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("不需要調(diào)試請忽略>>>>>\t調(diào)試server未能連接:\n" + e.Message);
}
finally
{
if (openDebugFinish)
{
Debug.LogError("成功連接調(diào)試server\n" + path);
}
}
}
#endif
m_LuaScripts = new Dictionary<string, byte[]>();
}
五、運行unity測試斷點功能首先要確保Lua入口的斷點調(diào)試代碼為true,然后按下F5開啟斷點調(diào)試模式,再運行Unity,否則會報錯,這個順序不能錯。連接成功后,VSCode的控制臺會看到以下信息,就證明是斷點調(diào)試開啟了
?文章來源地址http://www.zghlxwxcb.cn/news/detail-548744.html文章來源:http://www.zghlxwxcb.cn/news/detail-548744.html
?
到了這里,關(guān)于VsCode使用EmmyLua插件調(diào)試Unity工程Lua代碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!