JetBrains Rider

JetBrains Rider is a commercial JetBrains IDE for C# and C++ that uses the same solution system as Visual Studio.

备注

This documentation is for contributions to the game engine, and not using JetBrains Rider as a C# or GDScript editor. To code C# or GDScript in an external editor, see the C# guide to configure an external editor.

导入项目

You will need to install Python in your development environment along with MinGW. You will also need the Visual Studio C++ Build Tools, which you can install using the Visual Studio Installer. Ensure all dependencies are installed before you continue to the next steps.

小技巧

如果 Visual Studio 已经是你的主要 IDE,那么你可以在 Rider 中使用同一个解决方案文件。Rider 和 Visual Studio 使用相同的解决方案文件格式,所以你可以在两个 IDE 间切换,无需重新构建解决方案文件。切换 IDE 时需要更改调试配置。

Rider requires a solution file to work on a C++ project. While Godot does not come with a solution file, it can be generated using SCons.

  • 导航到Godot根文件夹, 打开命令提示符或PowerShell窗口.

  • 将以下命令复制粘贴并运行以生成解决方案。

scons platform=windows vsproj=yes dev_build=yes

vsproj 参数说明要生成 Visual Studio 项目。dev_build 参数确保生成中包括了调试符号,允许你进行一系列操作,例如使用断点逐步执行代码。

  • If you have Rider setup as your main IDE for .sln, you can now open the project by double-clicking on the godot.sln in the project root or by using the Open option inside of Rider.

备注

Rider could fail to build the solution. If that is the case, try running git clean -xdf to remove all traces of the previous build artifacts and regenerate the build files using the scons command again. Restarting the terminal and your development environment may help.

项目的编译与调试

Rider 拥有内置调试器,可以用来调试 Godot 项目。点击屏幕上方 Debug 图标来启动调试器。该调试器只能对项目管理器使用,要调试编辑器的话需要先配置调试器。

../../../_images/rider_run_debug.webp
  • Click on the Godot > Edit Configurations option at the top of the screen.

../../../_images/rider_configurations.webp
  • Ensure the following values for the C++ Project Run Configuration:

    • Exe Path : $(LocalDebuggerCommand)

    • Program Arguments: -e --path <path to the Godot project>

    • Working Directory: $(LocalDebuggerWorkingDirectory)

    • Before Launch has a value of "Build Project"

这会告知可执行文件在不使用项目管理器调试指定项目。应当使用项目文件夹的根路径,而非 project.godot 的文件路径。

../../../_images/rider_configurations_changed.webp
  • Finally click on "Apply" and "OK" to save the changes.

  • When you press the Debug icon at the top of the screen, JetBrains Rider will launch the Godot editor with the debugger attached.

或者,你也可以使用 运行 > 附加到进程 将调试器附加到运行中的 Godot 实例。

../../../_images/rider_attach_to_process.webp
  • You can find the Godot instance by searching for godot.editor and then clicking Attach with LLDB

../../../_images/rider_attach_to_process_dialog.webp

Please consult the JetBrains Rider documentation for any specific information about the JetBrains IDE.