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...
ResourceFormatSaver
繼承: RefCounted < Object
將特定資源型別保存到檔案。
說明
當你從編輯器執行此操作或使用 ResourceSaver 單例時,引擎可以節省資源。這要歸功於多個 ResourceFormatSaver,每個都處理自己的格式並由引擎自動呼叫。
預設情況下,Godot 將資源保存為 .tres(基於文字)、.res(二進位)或其他內建格式,但你可以選擇通過擴充這個類來建立自己的格式。請務必遵守記錄的返回型別和值。你應該給它一個全域類別名稱 class_name 以便它被註冊。與內建的 ResourceFormatSaver 一樣,它會在保存其識別型別的資源時自動呼叫。你也可以實作一個 ResourceFormatLoader。
方法
_get_recognized_extensions(resource: Resource) virtual const |
|
_recognize(resource: Resource) virtual const |
|
_recognize_path(resource: Resource, path: String) virtual const |
|
方法說明
PackedStringArray _get_recognized_extensions(resource: Resource) virtual const 🔗
返回可用於保存資源對象的副檔名列表,前提是該資源物件已被識別(見 _recognize())。
bool _recognize(resource: Resource) virtual const 🔗
返回此保存程式能否保存給定的資源物件。
bool _recognize_path(resource: Resource, path: String) virtual const 🔗
如果該saver可以處理給定的保存路徑,則返回true,否則返回false。
如果未實作該方法,則預設行為是檢查路徑的副檔名是否在_get_recognized_extensions()提供的範圍內。
Error _save(resource: Resource, path: String, flags: int) virtual 🔗
將給定的資源物件保存到目標path中的檔中。 flags是一個位掩碼,由SaverFlags常數組成。
成功時返回@GlobalScope.OK,失敗時返回Error常數。
Error _set_uid(path: String, uid: int) virtual 🔗
為給定 path 處的資源設定新的 UID。成功時返回 @GlobalScope.OK,失敗時返回 Error 常數。