Visual Studio Code

Visual Studio Code is a free cross-platform IDE by Microsoft (not to be confused with Visual Studio).

导入项目

  • Make sure the C/C++ extension is installed. You can find instructions in the official documentation.
  • 现在在VS Code中打开克隆的godot文件夹**文件 > 打开文件夹…**。
  • 按Ctrl + Shift + P打开命令提示符窗口,然后输入 Configure Task

../../../_images/vscode_configure_task.png

  • Select the Create tasks.json file from template option.

../../../_images/vscode_create_tasksjson.png

  • 然后选择“其他”。

../../../_images/vscode_create_tasksjson_others.png

  • Within the tasks.json file find the "tasks" array and add a new section to it:
  1. {
  2. "label": "build",
  3. "type": "shell",
  4. "command": "scons",
  5. "group": "build",
  6. "args": [
  7. "platform=x11", // Change to your current platform
  8. "target=debug",
  9. "-j4"
  10. ],
  11. "problemMatcher": "$msCompile"
  12. }

../../../_images/vscode_3_tasks.json.png

An example of a filled out tasks.json.

Arguments can be different based on your own setup and needs. See 构建系统介绍 for a full list of arguments.

Debugging the project

为了构建项目,我们需要配置文件 launch.json

  • 按Ctrl + Shift + D打开``运行’’面板。
  • If launch.json file is missing you will be prompted to create a new one.

../../../_images/vscode_1_create_launch.json.png

  • Select C++ (GDB/LLDB). There may be another platform specific option here. If selected, adjust the configuration example provided accordingly.
  • Within the launch.json file find the "configurations" array and add a new section to it:
  1. {
  2. "name": "Launch",
  3. "type": "cppdbg",
  4. "request": "launch",
  5. // Change the path below to match your current platform.
  6. "program": "${workspaceFolder}/bin/godot.x11.tools.64",
  7. // Change the arguments below for the project you want to test with.
  8. // To run the project instead of editing it, remove the "--editor" argument.
  9. "args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
  10. "stopAtEntry": false,
  11. "cwd": "${workspaceFolder}",
  12. "environment": [],
  13. "externalConsole": true,
  14. "MIMode": "gdb",
  15. "setupCommands": [
  16. {
  17. "description": "Enable pretty-printing for gdb",
  18. "text": "-enable-pretty-printing",
  19. "ignoreFailures": true
  20. }
  21. ],
  22. "preLaunchTask": "build"
  23. }

../../../_images/vscode_2_launch.json.png

An example of a filled out launch.json.

The name under program depends on your build configuration, e.g. godot.x11.tools.64 for 64-bit X11 platform with tools enabled.

If you run into any issues, ask for help in one of Godot’s community channels.