Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Visual Studio¶
Visual Studio Community 是微软的一个只面向 Windows 的 IDE,个人或者组织内的非商业使用是免费的。它有很多有用的功能,如内存视图、性能视图、源码控制等。
导入项目¶
Visual Studio需要一个解决方案文件来处理一个项目. 虽然Godot没有附带解决方案文件, 但可以使用SCons生成.
导航到Godot根文件夹, 打开命令提示符或PowerShell窗口.
- Run
scons platform=windows vsproj=yes dev_build=yes
to generate the solution with debug symbols.Thevsproj
parameter signals that you want Visual Studio solution generated.Thedev_build
parameter makes sure the debug symbols are included, allowing to e.g. step through code using breakpoints. 现在您可以通过双击项目根目录下的
godot.sln
或使用Visual Studio中的 打开项目或解决方案 选项来打开项目.从顶部菜单 Build [编译]来编译构建这个项目.
警告
Visual Studio must be configured with the C++ package. It can be selected in the installer:
![../../../_images/vs_1_install_cpp_package.png](../../../_images/vs_1_install_cpp_package.png)
调试项目¶
Visual Studio具有强大的调试器, 允许用户检查Godot的源代码, 在代码中的特定点中断, 检查当前的执行上下文, 并对代码库进行实时修改.
You can launch the project with the debugger attached using the Debug > Start Debugging option from the top menu. However, unless you want to debug the Project Manager specifically, you'd need to configure debugging options first. This is due to the fact that when the Godot Project Manager opens a project, the initial process is terminated and the debugger gets detached.
要配置与调试器一起使用的启动选项, 请使用顶部菜单中的 Project > Properties [项目 > 属性]:
![../../../_images/vs_2_project_properties.png](../../../_images/vs_2_project_properties.png)
Open the Debugging section and under Command Arguments add two new arguments: the
-e
flag opens the editor instead of the Project Manager, and the--path
argument tells the executable to open the specified project (must be provided as an absolute path to the project root, not theproject.godot
file; if the path contains spaces be sure to pass it inside double quotation marks).
![../../../_images/vs_3_debug_command_line.webp](../../../_images/vs_3_debug_command_line.webp)
要了解更多的命令行参数, 请参考 命令行教程 .
即使你在没有连接调试器的情况下启动项目, 也可以使用 Debug > Attach to Process... [调试 >附加到进程]菜单连接到正在运行的进程.
要检查一切是否正常,请将断点放在 main.cpp
中,然后按 F5 开始调试。
![../../../_images/vs_4_debugging_main.png](../../../_images/vs_4_debugging_main.png)
如果遇到问题, 也可在 Godot 社区论坛 中寻求帮助.