更改 Windows 的应用程序图标¶
默认情况下,导出项目的图标将是 Godot 图标。您很可能想要为您的项目更改它。在 Windows 上可以更改两种类型的图标:文件图标和任务栏图标。
创建 ICO 文件¶
Windows 无法使用 png 或 jpg 格式的应用图标。然而,它会使用 Windows专属的 ICO 格式。你可以在任何程序中创建应用图标,但需要用像 GIMP 这类程序转换成 ICO 文件。
这个视频教程展示了怎么用 GIMP 导出 ICO 文件。
也可以使用这个 ImageMagick 命令,将 PNG 图像转换为 hiDPI 友好的 ICO 文件:
magick convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico
根据你所安装的 ImageMagick 的版本的不同,你可能会需要把 magick
去掉,运行以下命令:
convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico
警告
为了使 ICO 文件有效地替换默认 Godot 图标,它必须包含默认 Godot 图标所包含的所有尺寸:16×16、32×32、48×48、64×64、128×128、256×256。如果该 ICO 文件未包含所有尺寸,没有被覆盖的尺寸将保留默认 Godot 图标。
上面的 ImageMagick 命令考虑到了这一点。
更改任务栏图标¶
任务栏图标是项目运行时显示在任务栏上的图标。

要更改任务栏图标,请前往项目 → 项目设置 → Application → Config → Windows Native Icon(应用程序 → 配置 → Windows 原生图标)。单击文件夹图标,然后选择所需的 ICO 文件。

这个设置只会修改 Windows 导出的游戏图标。设置 macOS 的图标请使用 Macos Native Icon
(macOS 原生图标)。其他平台请使用 Icon
(图标)设置。
更改文件图标¶
警告
There are known issues when changing the application icon in executables that embed a PCK file. It's recommended to avoid using rcedit for now if you choose to enable the Embed Pck option for your Windows export preset in the Export dialog.
文件图标是您单击以启动游戏的可执行文件的图标.

Before selecting it in the export options, you will need to install an extra tool called rcedit. You can download it here.
下载后,您需要告诉 Godot 计算机上 rcedit 可执行文件的路径。请前往编辑器 → 编辑器设置 → Export → Windows。点击 rcedit 条目的文件夹图标。导航到并选择 rcedit 可执行文件。
备注
Linux 和 macOS 用户还需要安装 WINE 才能使用 rcedit。

您现在应该已准备好所有内容来更改文件图标。为此,您需要在导出时指定图标。转到项目 → 导出。假设您已经创建了 Windows Desktop 预设,请在 Application → Icon 字段中选择 ICO 格式的图标。

备注
If rcedit fails to change the icon, you can instead compile your own Windows export templates with the icon changed. To do so, replace platform/windows/godot.ico with your own ICO file before compiling export templates.
这样做之后,你就可以在项目的 Windows 导出预设中将你的导出模板指定为自定义导出模板。
测试结果¶
您现在可以导出项目了。如果一切正常,您应该看到:

备注
如果你的图标没有正确显示,在 Windows 10 中,请尝试清理图标缓存。实现方法是打开运行对话框并输入 ie4uinit.exe -ClearIconCache
或 ie4uinit.exe -show
。