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.

EditorPaths

繼承: Object

編輯器專用單例,返回特定於作業系統的各種資料檔案夾和檔的路徑。

說明

這個僅供編輯器使用的單例,可返回特定於作業系統的,到各種資料檔案夾和檔的路徑。它可以在編輯器外掛程式中使用,以確保檔被保存在各個作業系統的正確位置。

注意:這個單例在匯出的專案中是不可存取的。嘗試在匯出的專案中存取它會產生腳本錯誤,因為該單例沒有被宣告。為防止匯出專案中出現腳本錯誤,請使用 Engine.has_singleton() 檢查單例是否可用後再使用該單例。

注意:在 Linux/BSD 平臺上,Godot 遵守 XDG 基本目錄規範。可以按照規範覆蓋環境變數,來更改編輯器和專案資料路徑。

教學

方法

String

get_cache_dir() const

String

get_config_dir() const

String

get_data_dir() const

String

get_project_settings_dir() const

String

get_self_contained_file() const

bool

is_self_contained() const


方法說明

String get_cache_dir() const 🔗

Returns the absolute path to the user's cache folder. This folder should be used for temporary data that can be removed safely whenever the editor is closed (such as generated resource thumbnails).

Default paths per platform:

- Windows: %LOCALAPPDATA%\Godot\
- macOS: ~/Library/Caches/Godot/
- Linux: ~/.cache/godot/

String get_config_dir() const 🔗

Returns the absolute path to the user's configuration folder. This folder should be used for persistent user configuration files.

Default paths per platform:

- Windows: %APPDATA%\Godot\                    (same as `get_data_dir()`)
- macOS: ~/Library/Application Support/Godot/  (same as `get_data_dir()`)
- Linux: ~/.config/godot/

String get_data_dir() const 🔗

Returns the absolute path to the user's data folder. This folder should be used for persistent user data files such as installed export templates.

Default paths per platform:

- Windows: %APPDATA%\Godot\                    (same as `get_config_dir()`)
- macOS: ~/Library/Application Support/Godot/  (same as `get_config_dir()`)
- Linux: ~/.local/share/godot/

String get_project_settings_dir() const 🔗

Returns the relative path to the editor settings for this project. This is usually "res://.godot/editor". Projects all have a unique subdirectory inside the settings path where project-specific editor settings are saved.


String get_self_contained_file() const 🔗

返回自包含檔的絕對路徑,該檔會使目前 Godot 編輯器實例被視為是自包含的。如果目前 Godot 編輯器實例不是自包含的,則返回一個空字串。另見 is_self_contained()


bool is_self_contained() const 🔗

如果編輯器被標記為是自包含的,則返回 true,否則返回 false。啟用自包含模式後,使用者配置、資料和快取檔案將保被存在編輯器二進位檔案旁邊的 editor_data/ 資料夾中。這使得便攜使用更容易,並確保 Godot 編輯器最大限度地減少將檔寫入到它自己的資料夾之外的情況。自包含模式不適用於匯出的專案。

當編輯器未運作時,可以通過在與編輯器二進位檔案或 macOS .app 組合包相同的檔案夾中建立名為 ._sc__sc_ 的檔來啟用自包含模式。另見 get_self_contained_file()

注意:在 macOS 上,應當在使用自包含模式前手動移除隔離旗標,見《在 macOS 上運作》

注意:在 macOS 上,將 _sc_ 或任何其他檔案放入 .app 組合包中會破壞其數位簽章,使其不再便攜,請考慮改為放在與 .app 組合包相同的資料夾中。

注意:Godot 的 Steam 版本預設使用自包含模式。