斷點調試三部曲(二):引入Emmylua插件
-
用Vscode安裝插件
-
-
打開你的lua文件所在目錄,然后創建json文件
-
-
-
修改《Test_C.cs》文件
-
端口占用會報這個錯誤,修改下端口號就好
-
安裝完Emmylua插件后,會獲得一個dll文件,我的路徑是:C:\Users\Administrator\.vscode\extensions\tangzx.emmylua-0.3.49\debugger\emmy\windows\x64
-
-
把這個文件拷貝到unity工程Assets同級目錄下
-
-
修改《Test_L.lua》文件
-
-
首次啟動,若不先啟動unity,會報錯
《Test_C.cs》 新增代碼,update() private void Update() { if (Input.GetKeyDown(KeyCode.Q)) { func.Call(gameObject); } } 新增代碼,LuaStart() .... string path = Directory.GetCurrentDirectory(); if (File.Exists(path + "/emmy_core.dll")) { env.DoString(" local dbg = require('emmy_core') dbg.tcpListen('localhost', 9898)"); } ...
《launch.json》 { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "emmylua_new", "request": "launch", "name": "EmmyLua New Debug", "host": "localhost", "port": 9898, "ext": [ ".lua", ".lua.txt", ".lua.bytes" ], "ideConnectDebugger": true } ] }