Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Visual Studio Code¶
Visual Studio Code es un editor de código gratuito multiplataforma desarrollado por Microsoft (no confundir con Visual Studio).
Importando el proyecto¶
Asegúrate de tener instalada la extensión C/C++ en Visual Studio Code. Puedes encontrar instrucciones en la documentación oficial. Alternativamente, puedes usar clangd en su lugar.
Cuando uses la extensión clangd, ejecuta
scons compiledb=yes
.Desde la pantalla principal de Visual Studio Code, abre la carpeta raíz de Godot con File > Open Folder....
Presiona Ctrl + Shift + P para abrir la ventana del símbolo de comando y escribe Configure Task.
Selecciona la opción Create tasks.json file from template.
Luego selecciona Others.
If there is no such option as Create tasks.json file from template available, either delete the file if it already exists in your folder or create a
.vscode/tasks.json
file manually. See Tasks in Visual Studio Code for more details on tasks.Dentro del archivo
tasks.json
, busca el array"tasks"
y agrega una nueva sección a él:{ "label": "build", "group": "build", "type": "shell", "command": "scons", "args": [ // enable for debugging with breakpoints "dev_build=yes", ], "problemMatcher": "$msCompile" }
Los parámetros pueden ser diferente según tu configuración y necesidades. Ver Introducción al sistema de compilación para una lista completa de parámetros.
Depurando el proyecto¶
Para ejecutar y depurar el proyecto, necesitas crear una nueva configuración en el archivo launch.json
.
Presiona Ctrl + Shift + D para abrir el panel de ejecución (Run).
Si falta el archivo
launch.json
, se te pedirá que crees uno nuevo.
Selecciona C++ (GDB/LLDB). Puede haber otra opción específica de plataforma aquí. Si está seleccionada, ajusta el ejemplo de configuración proporcionado en consecuencia.
Dentro del archivo
launch.json
, encuentra la matriz"configurations"
y agrega una nueva sección a la misma:
{
"name": "Launch Project",
"type": "lldb",
"request": "launch",
// Change to godot.linuxbsd.editor.dev.x86_64.llvm for llvm-based builds.
"program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64",
// Change the arguments below for the project you want to test with.
// To run the project instead of editing it, remove the "--editor" argument.
"args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "build"
}
{
"name": "Launch Project",
"type": "cppdbg",
"request": "launch",
// Change to godot.linuxbsd.editor.dev.x86_64.llvm for llvm-based builds.
"program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64",
// Change the arguments below for the project you want to test with.
// To run the project instead of editing it, remove the "--editor" argument.
"args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"setupCommands":
[
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
{
"name": "Launch Project",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/godot.windows.editor.dev.x86_64.exe",
// Change the arguments below for the project you want to test with.
// To run the project instead of editing it, remove the "--editor" argument.
"args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "internalConsole",
"visualizerFile": "${workspaceFolder}/platform/windows/godot.natvis",
"preLaunchTask": "build"
}
Nota
Debido a problemas de rendimiento esporádicos, se recomienda usar LLDB en lugar de GDB en sistemas basados en Unix. Asegúrate de que la extensión CodeLLDB esté instalada.
If you encounter issues with lldb, you may consider using gdb (see the LinuxBSD_gdb configuration).
Do note that lldb may work better with LLVM-based builds. See Compiling for Linux, *BSD for further information.
The name under program
depends on your build configuration,
e.g. godot.linuxbsd.editor.dev.x86_64
for 64-bit LinuxBSD platform with
platform=editor
and dev_build=yes
.
Si tienes algún problema, busca ayuda en alguno de los canales de la comunidad Godot.
Truco
To get linting on class reference XML files, install the vscode-xml extension.