Closed ahyee closed 10 months ago
This may be because your chunkname does not comply with the general rules of Lua. The general format for a Lua chunkname is aaa/b/ccc.lua. You can check the chunkname by printing debug.getinfo(1).source or use dbg.breakHere() to forcefully break and inspect it. If you are developing with Unity's xLua, you can modify the custom loader. If you are using a different framework, you can try modifying the usage of the lua loadbuffer interface.
This is what I printed out with debug.getinfo
@UI/UIVillage
but the break point still didnt worked.
you can try dbg.breakHere()
, this code needs to be inserted after dbg.tcpConnect
, is your editor Rider?
Yes I'm using Rider. I notice some of my lua file used . instead of /. Will it affect the file that i going to debug which is using /?
It is correct to use require 'aaaa.bbbbbbbb.cccccc'
in the code, but the corresponding chunkname needs to be changed to a/b/c
. Have you tried using dbg.breakHere()
?
dbg.breakHere() do work however I cant step over etc for it
Files outside of the assets may not be indexed by Rider. You can try using other editors like Visual Studio Code or IntelliJ IDEA.
I see.. I will test out others. I using Xlua in Unity. Is this what you mean by modify custom loader?
luaEnv.AddLoader((ref string filePath) => ReadFile(filePath));
private static byte[] ReadFile(string path) { if (path == "emmy_core") return null;
path = path.Replace('.', '/');
var fileFullPath = $"{FileService.GetAssetRootPath()}/lua_root/{path}.lua";
return System.IO.File.ReadAllBytes(fileFullPath);
}
You can take a look at the documentation for the AddLoader
function. It requires you to return the real path to filePath
. In other words, you need to modify the ReadFile
parameter to be ref string path
and assign fileFullPath
to path
.
thanks
Environment(环境)
What are the steps to reproduce this issue?(重现步骤?)
What happens?(出现什么问题?)
The IDE didn't stop at the breakpoint despite the log was printed out. And also the IDE showed its connected as below
Server(localhost:9966) open successfully, wait for connection... Connected.
What were you expecting to happen?(期望?)
Expect the IDE to stop at breakpoint
Any logs, error output, etc?(有没有什么log, error输出?)
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?(其它说明)
My Lua files was located outside of Unity Assets folder, not sure if this matter.