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...
編輯器圖示
當你建立新類別並讓它可用於腳本時,編輯器介面預設會以該類別所繼承的基底類別圖示顯示。絕大多數情況下,仍建議為新類別設計專屬圖示,以提升使用者體驗。
建立圖示
要建立新圖示,請先安裝向量繪圖軟體,例如開源的 Inkscape。
將包含所有編輯器圖示的 godot 儲存庫複製到本地端:
git clone https://github.com/godotengine/godot.git
The icons must be created in a vector graphics editor in SVG format. There are three main requirements to follow:
圖示尺寸必須為 16×16。於 Inkscape 可透過「檔案 > 文件屬性」設定大小。
線條應儘量吸附至像素,以便在低 DPI 下維持清晰。可於 Inkscape 開啟 16×16 格線協助對齊。
若使用者將編輯器設定為亮色主題,Godot 會根據 一組預設色彩對應 自動轉換圖示顏色,以確保有足夠對比。請盡量將圖示的色票限制在上述清單中的色彩,否則圖示在亮色背景下可能會難以辨識。
完成圖示設計後,將檔案儲存至剛才複製的儲存庫的 editor/icons 目錄下,檔名須符合預期類別名稱且區分大小寫。例如要為 CPUParticles2D 建立圖示,檔名應為 CPUParticles2D.svg。
小訣竅
You can also browse all existing icons on the Godot editor icons website.
Import options for custom icons
For custom icons that are present in projects (as opposed to the engine source code), there are two import options you should enable:
Scaling for hiDPI displays
Icons need to be scaled properly on hiDPI displays to ensure they remain crisp and large enough to be readable.
To ensure the icon is rendered at a correct scale on hiDPI displays, select the SVG file in the FileSystem dock, enable the Editor > Scale with Editor Scale option in the Import dock and click . Note that this option is only available for icons in SVG format, as it requires the use of a vector format to work.
亮色主題下的圖示色彩轉換
To ensure the icon has its colors converted when the user is using a light theme, select the SVG file in the FileSystem dock, enable the Editor > Convert Colors with Editor Theme option in the Import dock and click . Note that this option is only available for icons in SVG format, as it requires the use of a vector format to work.
圖示最佳化
由於編輯器會在載入時即渲染一次 SVG,圖示檔案應盡量保持精簡,以利高效解析。當 pre-commit hook 執行時,會自動使用 svgo 最佳化 SVG。
備註
最佳化步驟不會明顯影響圖示品質,但會移除如輔助線等僅供編輯時用的資訊。因此,若需日後修改,建議保留原始 SVG 檔。
整合與分享圖示
若你要貢獻至 Godot 本體,請發送 Pull Request,將最佳化後的圖示加入主儲存庫的 editor/icons 目錄。重新編譯引擎後,新類別的圖示就會自動套用。
你也可以於自製模組中建立專屬的自訂圖示。如果該模組不打算整合進 Godot 主專案,則無需額外發送 Pull Request,自訂圖示會在模組內自動生效。
For specific instructions on how to create module icons, refer to Creating custom module icons.
疑難排解
若圖示未出現在編輯器中,請檢查:
每個圖示的檔名有無遵循上述命名規範。
The
svgmodule is enabled at compile-time (it is enabled by default). Without this module, icons won't appear in the editor at all.