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...
EditorPaths
繼承: Object
編輯器專用單例,返回特定於作業系統的各種資料檔案夾和檔的路徑。
說明
這個僅供編輯器使用的單例,可返回特定於作業系統的,到各種資料檔案夾和檔的路徑。它可以在編輯器外掛程式中使用,以確保檔被保存在各個作業系統的正確位置。
注意:這個單例在匯出的專案中是不可存取的。嘗試在匯出的專案中存取它會產生腳本錯誤,因為該單例沒有被宣告。為防止匯出專案中出現腳本錯誤,請使用 Engine.has_singleton() 檢查單例是否可用後再使用該單例。
注意:在 Linux/BSD 平臺上,Godot 遵守 XDG 基本目錄規範。可以按照規範覆蓋環境變數,來更改編輯器和專案資料路徑。
教學
方法
get_cache_dir() const |
|
get_config_dir() const |
|
get_data_dir() const |
|
get_project_settings_dir() const |
|
get_self_contained_file() const |
|
is_self_contained() const |
方法說明
String get_cache_dir() const 🔗
回傳使用者快取資料夾的絕對路徑。該資料夾應該用於暫時資料,關閉編輯器時應該能夠安全地移除這些資料(例如生成的資源預覽圖)。
各平台的預設路徑:
- Windows: %LOCALAPPDATA%\Godot\
- macOS: ~/Library/Caches/Godot/
- Linux: ~/.cache/godot/
String get_config_dir() const 🔗
回傳使用者設定資料夾的絕對路徑。該資料夾應該用於持久化的使用者設定檔案。
各平台的預設路徑:
- Windows: %APPDATA%\Godot\ (同 `get_data_dir()`)
- macOS: ~/Library/Application Support/Godot/ (同 `get_data_dir()`)
- Linux: ~/.config/godot/
回傳使用者資料資料夾的絕對路徑。該資料夾應該用於持久化的使用者資料檔案,例如已安裝的匯出範本。
各平台的預設路徑:
- Windows:%APPDATA%\Godot\ (同 `get_config_dir()` )
- macOS:~/Library/Application Support/Godot/ (同 `get_config_dir()` )
- Linux:~/.local/share/godot/
String get_project_settings_dir() const 🔗
回傳此專案特定的編輯器設定的相對路徑。該路徑通常為 "res://.godot/editor"。所有專案在設定路徑內都有一個唯一的子目錄,用於儲存專案特定的編輯器設定。
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 版本預設使用自包含模式。