Can't get Unity Debugger to work #815
-
When I run "lua require("dap").continue()" I get this output: UnityDebug: Initializing Do anyone know what I am doint wrong? This is my current setup: local dap = require('dap') dap.adapters.unity = { dap.configurations.cs = { require("dapui").setup({}) |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
please add 'path' parameter. dap can find your Unity proccess. dap.configurations.cs = { |
Beta Was this translation helpful? Give feedback.
-
@Imlimp @nagaohiroki How are you able to configure the adapter now that VSDebug has been deprecated and newer versions of Unity are using Unity for VS Code extension? |
Beta Was this translation helpful? Give feedback.
-
@yemibox51 dap.adapters.vstuc= {
type = 'executable',
command = vim.env.HOME .. '/AppData/Roaming/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.14~x64/dotnet.exe',
args = {vim.env.HOME .. '/.vscode/extensions/visualstudiotoolsforunity.vstuc-0.9.3/bin/UnityDebugAdapter.dll'},
name = 'Attach to Unity',
}
dap.configurations.cs = {
{
type = 'vstuc',
request = 'attach',
name = 'Attach to Unity',
-- path = 'UnityProject/Library/EditorInstance.json -- not working?
logFile = vim.env.HOME .. "/Desktop/vstuc.log",
endPoint = "127.0.0.1:56912" -- from Unity Editor.log
},
} |
Beta Was this translation helpful? Give feedback.
-
instead absolute path, you can use path = vim.fn.getcwd().."/Library/EditorInstance.json", as for vstuc, it may has some optimization that cant fit in neovim based on the trace
Unlike the old debugger provided by unity,vstuc is not open-source.so it need some decompiling work. |
Beta Was this translation helpful? Give feedback.
-
Breakpoints not working (logs have a null reference exception), but I hacked together a little way to make connecting to unity more consistent (since that port number keeps changing each time you open it) local vstuc_path = os.getenv("HOME") ..
"/.vscode/extensions/visualstudiotoolsforunity.vstuc-1.0.1/bin/"
dap.adapters.vstuc = {
type = 'executable',
command = 'dotnet',
args = {
vstuc_path .. 'UnityDebugAdapter.dll'
}
}
dap.configurations.cs = {
{
name = 'Attach to Unity',
type = 'vstuc',
request = 'attach',
path = vim.fn.getcwd() .. "/Library/EditorInstance.json",
logFile = vim.env.HOME .. "/vstuc.log",
endPoint = function()
local system_obj = vim.system(
{ "dotnet", vstuc_path .. "UnityAttachProbe.dll" })
local probe_result = system_obj:wait(2000).stdout
if probe_result == nil or #probe_result == 0 then
print("No endpoint found (is unity running?)")
return ""
end
local pattern = [["debuggerPort":(%d+)]]
local port = string.match(probe_result, pattern)
if port == nil or #port == 0 then
print("Failed to parse debugger port")
return ""
end
return "127.0.0.1:" .. port
end,
}
} Running UnityAttachProbe.dll gets you output like this:
and it will give you nothing if there is no unity instance running |
Beta Was this translation helpful? Give feedback.
please add 'path' parameter. dap can find your Unity proccess.
dap.configurations.cs = {
{
type = 'unity',
request = 'attach',
name = 'Unity Editor',
path = 'YourUnityProject/Library/EditorInstance.json'
}
}