更改Windows的应用程序图标

默认情况下,导出项目的图标将是Godot图标。您很可能想要为您的项目更改它。在Windows上可以更改两种类型的图标:文件图标和任务栏图标。

Creating an ICO file

Windows does not use formats such as png or jpg for application icons. Instead, it uses a Windows-only format called ICO. You can create your application icon in any program but you will have to convert it to an ICO file using a program such as GIMP.

This video tutorial goes over how to export an ICO file with GIMP.

也可以使用这个 ImageMagick 命令,将PNG图像转换为hiDPI友好的ICO文件:

magick convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico

更改任务栏图标

任务栏图标是项目运行时显示在任务栏上的图标。

../../../_images/icon_taskbar_icon.png

To change the taskbar icon, go to Project → Project Settings → Application → Config → Windows Native Icon. Click on the folder icon and select your ICO file.

../../../_images/icon_project_settings.png

This setting only changes the icon for your exported game on Windows. To set the icon for macOS, use Macos Native Icon. And for any other platform, use the Icon setting.

更改文件图标

警告

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.

文件图标是您单击以启动游戏的可执行文件的图标。

../../../_images/icon_file_icon.png

在导出选项中选择它之前,您需要额外安装一个名为 rcedit 的工具。您可以在 这里 下载它。

下载后,您需要告诉Godot,计算机上rcedit可执行文件的路径。转到 编辑器→编辑器设置→导出→Windows 。单击 rcedit 条目的文件夹图标。导航到并选择rcedit可执行文件。

注解

Linux和macOS用户还需要安装 WINE 才能使用rcedit。

../../../_images/icon_rcedit.png

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

../../../_images/icon_export_settings.png

注解

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.

Once this is done, you can specify your export templates as custom export templates in your project's Windows export preset.

测试结果

您现在可以导出项目了。如果它正常工作,您应该看到:

../../../_images/icon_result.png

注解

If your icon isn't showing up properly, on Windows 10, try clearing the icon cache. To do so, open the Run dialog and enter ie4uinit.exe -ClearIconCache or ie4uinit.exe -show.