Visual Studio Code¶
Visual Studio Code is a free cross-platform code editor by Microsoft (not to be confused with Visual Studio).
Projekt importieren¶
Make sure the C/C++ extension is installed. You can find instructions in the official documentation. Alternatively, clangd can be used instead.
When using the clangd extension, run
scons compiledb=yes
.Öffnen Sie im Hauptbildschirm von Visual Studio-Code den Godot-Stammordner mit Datei > Ordner öffnen ....
Drücken Sie Strg + Umschalt + P, um das Eingabeaufforderungsfenster zu öffnen und Configure Task einzugeben.

Wählen Sie die Option task.json-Datei aus Vorlage erstellen.

dann wählen Sie Others.

Suchen Sie in der Datei
task.json
das Array"tasks"
und fügen Sie einen neuen Abschnitt hinzu:
{
"label": "build",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
"-j $(nproc)"
],
"problemMatcher": "$msCompile"
}
{
"label": "build",
"group": "build",
"type": "shell",
"command": "scons",
"args": [
// Use this when your default shell is Command Prompt (cmd.exe).
"-j %NUMBER_OF_PROCESSORS%",
// Use this when your default shell is PowerShell.
"-j $env:NUMBER_OF_PROCESSORS"
],
"problemMatcher": "$msCompile"
}

Ein Beispiel eines ausgefüllten Tasks.json
.¶
Die Argumente können je nach Einrichtung und Anforderungen unterschiedlich sein. Eine vollständige Liste der Argumente finden Sie unter Einführung in das Buildsystem.
Debuggen des Projekts¶
Um das Projekt auszuführen und zu debuggen, müssen Sie eine neue Konfiguration in der Datei launch.json
erstellen.
Drücken Sie Strg + Umschalt + D, um das Ausführen-Panel zu öffnen.
Wenn die Datei
launch.json
fehlt, werden Sie aufgefordert diese neu zu erstellen.

Wählen Sie C++ (GDB/LLDB). Möglicherweise gibt es hier eine andere plattformspezifische Option. Wenn ausgewählt, passen Sie das bereitgestellte Konfigurationsbeispiel entsprechend an.
Suchen Sie in der Datei
launch.json
das Array"configurations"
und fügen Sie einen neuen Abschnitt hinzu:
{
"name": "Launch Project",
"type": "lldb",
"request": "launch",
// Change to godot.x11.tools.64.llvm for llvm-based builds.
"program": "${workspaceFolder}/bin/godot.x11.tools.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.x11.tools.64.llvm for llvm-based builds.
"program": "${workspaceFolder}/bin/godot.x11.tools.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.tools.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"
}

Ein Beispiel für ein ausgefülltes launch.json
.¶
Bemerkung
Due to sporadic performance issues, it is recommended to use LLDB over GDB on Unix-based systems. Make sure that the CodeLLDB extension is installed.
Wenn Sie Probleme mit lldb feststellen, wollen Sie möglicherweise gdb probieren (siehe X11_gdb Konfiguration).
Do note that lldb may work better with llvm-based builds. See Kompilieren für X11 (Linux, *BSD) for further information.
Der Name unter program
hängt von Ihrer Build-Konfiguration ab, z.B. godot.x11.tools.64
für 64-Bit-X11-Plattform mit aktivierten tools
.
Wenn Sie auf Probleme stoßen, bitten Sie um Hilfe in einem von Godots Community-Kanälen.