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.

为 Windows 导出

参见

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

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

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

Code signing

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.

环境变量

You can use the following environment variables to set export options outside of the editor. During the export process, these override the values that you set in the export menu.

Windows export environment variables

Export option

Environment variable

Encryption / Encryption Key

GODOT_SCRIPT_ENCRYPTION_KEY

Options / Codesign / Identity Type

GODOT_WINDOWS_CODESIGN_IDENTITY_TYPE

Options / Codesign / Identity

GODOT_WINDOWS_CODESIGN_IDENTITY

Options / Codesign / Password

GODOT_WINDOWS_CODESIGN_PASSWORD