Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

为 Windows 导出

参见

这个页面描述的是如何将 Godot 项目导出到 Windows。如果你想要找的是从源码编译编辑器或导出模板二进制文件,请阅读 为 Windows 平台编译

在 PC 上分发游戏的最简单方法是复制可执行文件(godot.exe),将文件夹压缩,然后发送给别人。然而,这样一般并不理想。

Godot 在使用导出系统时,为 PC 分发提供了一种更为优雅的方法。为 Windows 导出时,导出器将提取所有项目文件并创建一个 data.pck 文件。该文件与特别优化的二进制文件捆绑在一起,更小、更快,并且不包含编辑器和调试器。

启用代码签名

Godot is capable of automatic code signing on export. To do this you must have the Windows SDK (on Windows) or osslsigncode (on any other OS) installed. You will also need a package signing certificate, information on creating one can be found here.

警告

如果你用内嵌的PCK文件导出到Windows, 你将无法签名程序, 因为它会崩溃.

在Windows上,PCK嵌入也会在杀毒软件中造成误报. 因此, 建议避免使用它, 除非你的项目通过Steam发布, 因为这样就绕过了代码签名和防病毒检查.

场景布置

Settings need to be changed in two places. First, in the editor settings, under Export > Windows. Click on the folder next to the Sign Tool setting, if you're using Windows navigate to and select SignTool.exe, if you're on a different OS select osslsigncode.

../../_images/windows_editor_settings.png

The second location is the Windows export preset, which can be found in Project > Export.... Add a windows desktop preset if you haven't already. Under options there is a code signing category.

../../_images/windows_export_codesign.png

Enabled must be set to true, and Identity must be set to the signing certificate. The other settings can be adjusted as needed. Once this is Done Godot will sign your project on export.

环境变量

你可以使用以下环境变量在编辑器外部设置导出选项。在导出过程中,这些值会覆盖你在导出菜单中设置的值。

Windows 导出环境变量

导出选项

环境变量

加密 / 密钥

GODOT_SCRIPT_ENCRYPTION_KEY

选项 / 代码签名 / 身份类型

GODOT_WINDOWS_CODESIGN_IDENTITY_TYPE

选项 / 代码签名 / 身份

GODOT_WINDOWS_CODESIGN_IDENTITY

选项 / 代码签名 / 密码

GODOT_WINDOWS_CODESIGN_PASSWORD