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...
為 Windows 更改應用程式圖示
預設情況下,匯出專案的圖示會是 Godot 圖示。通常我們會想為專案更改圖示。在 Windows 有兩種型別的圖示可以更改:檔案圖示與工作列圖示。
Creating a custom ICO file
備註
Since Godot 4.1, Godot can create an ICO file for you based on the icon file defined in the Windows export preset. This icon file can be in PNG, WebP or SVG format. If no icon is defined in the Windows export preset, the application/config/icon project setting is used automatically instead.
This means you no longer need to follow the steps in this section to manually create an ICO file, unless you wish to have control over the icon design depending on its displayed size. Note that even if Godot creates the ICO file for you, you still need to set up rcedit so that the file icon actually changes.
Windows does not use formats such as PNG or JPEG 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.
這個影片教學 (英語) 說明了如何用 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 命令考慮到了這一點。
更改工作列圖示
工作列圖示即為專案執行時顯示在工作列上的圖示。

To change the taskbar icon, go to
Project > Project Settings > Application > Config, make sure
Advanced Settings are enabled to see the setting, then go to
Windows Native Icon
. Click on the folder icon and select your ICO file.

該設定只會更改匯出至 Windows 平台的遊戲。若要設定 macOS 上的圖示,請使用 Macos Native Icon
。而其他的平台則使用 Icon
設定。
更改檔案圖示
從 Godot 3.5 開始,你可以使用 godoticon 來修改檔圖示,無需外部工具。使用這種方法修改圖示應該對內嵌 PCK 的可執行檔也有效。
檔案圖示即為啟動專案時點擊的執行檔的圖示。

與匯出選項中選擇圖示前,還必須要安裝一個名為 rcedit 的額外工具。可以在 此處 下載。
After downloading, you need to tell Godot the path to the rcedit executable on your computer. Go to Editor > Editor Settings > Export > Windows. Click on the folder icon for the rcedit entry. Navigate to and select the rcedit executable.
備註
Linux 與 macOS 使用者還需要安裝 WINE 來使用 rcedit。
On macOS, make sure to use a 64-bit version of both WINE and rcedit since 32-bit applications aren't supported anymore.

You should now have everything in place to change the file icon. To do that, you will need to specify the icon when exporting. Go to Project > Export. Assuming you have already created a Windows Desktop preset, select your icon in ICO format in the Application > Icon field.
警告
所有提供的元資料必須有效。最重要的是,版本標識符**必須**採用“major.minor.patch.revision”的形式,其中每個組件都是必需的並且是正整數。例如,「1.2.0.0」有效,但「1.2.0」無效。
如果您在匯出預設中提供無效元資料,應用程式圖示將不會更改,因為 rcedit 將無法更改可執行檔案的元資料。

備註
若無法使用 rcedit 更改圖示,則可以改而 自行編譯更改好圖示的客製化 Windows 匯出樣板 。要在編譯的匯出樣板裡更改圖示,請在 編譯匯出樣板前 將 platform/windows/godot.ico 更改為你要使用的 ICO 檔案。
完成之後,即可在專案的 Windows 匯出預設中將匯出樣板指定為客製化匯出樣板。
測試結果
現在可以匯出專案了。若一切正常,應該可以看到這個結果:

備註
若在 Windows 10 上圖示沒有正常顯示,請試試清除圖示快取。要清除快取,請開啟 執行 並呼叫指令 ie4uinit.exe -ClearIconCache
或 ie4uinit.exe -show
。