Unity搭配VS Code使用
1.Unity编辑器中设置External Tools为VS Code
Edit->Preferces->External Tools->Visual Studio Code
2.VS Code安装Unity插件
- 快捷键“Ctrl+Shift+X”
- 输入“Unity”
- 点击“Install”
3.下载安装.Net
下载 .NET 8.0 (Linux、macOS 和 Windows)
- 下载完成后安装.Net
- 输入测试查看版本
dotnet --version
4.配置.Net Install Tool
VS Code插件“.Net Install Tool”->Extesion Settings->Edit in settting.json
{
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-dotnettools.csharp",
"path": "C:\\Program Files\\dotnet\\dotnet.exe"
},
{
"extensionId": "visualstudiotoolsforunity.vstuc",
"path": "C:\\Program Files\\dotnet\\dotnet.exe"
}
]
}
5.配置Launch.json
.vscode->launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
}
]
}
重启电脑
6.调试
打断点->按F5->开始调试
References:
VSCode调试Unity准备工作_vscode 调试unity-CSDN博客