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 est un éditeur de code multiplateforme gratuit de Microsoft (à ne pas confondre avec Visual Studio).
Importation du projet¶
Make sure the C/C++ extension is installed. You can find instructions in the official documentation. Alternatively, clangd can be used instead.
Lorsque vous utilisez l'extension glangd, lancer
scons compiledb=yes
.Depuis l'écran principal du Visual Studio Code, ouvrez le dossier racine de Godot avec File > Open Folder....
Appuyez sur Ctrl + Shift + P pour ouvrir la fenêtre d'invite de commande et entrez Configure Task.
Sélectionnez l'option Create tasks.json file from template.
Sélectionnez ensuite 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.Dans le fichier
tasks.json
, trouvez le tableau"tasks"
et ajoutez-y une nouvelle section :{ "label": "build", "group": "build", "type": "shell", "command": "scons", "args": [ // enable for debugging with breakpoints "dev_build=yes", ], "problemMatcher": "$msCompile" }
Les arguments peuvent être différents selon votre propre configuration et vos besoins. Voir Introduction au buildsystem pour une liste complète des arguments.
Débogage du projet¶
Pour exécuter et déboguer le projet, vous devez créer une nouvelle configuration dans le fichier launch.json
.
Appuyez sur Ctrl + Shift + D pour ouvrir le panneau Run.
Si le fichier
launch.json
est manquant, vous serez invité à en créer un nouveau.
Sélectionnez C++ (GDB/LLDB). Il peut y avoir une autre option spécifique à la plate-forme ici. Si elle est sélectionnée, adaptez l'exemple de configuration fourni en conséquence.
Dans le fichier
launch.json
, trouvez le tableau"configurations"
et ajoutez-y une nouvelle section :
{
"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"
}
Note
En raison de problèmes de performances sporadiques, il est recommandé d'utiliser LLDB plutôt que GDB sur les systèmes basés sur Unix. Assurez-vous que l'extension CodeLLDB est installée.
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 vous rencontrez des problèmes, demandez de l'aide sur l'un des canaux communautaires de Godot.
Astuce
To get linting on class reference XML files, install the vscode-xml extension.