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...
ResourceSaver
Hérite de : Object
Un singleton pour sauvegarder des Resources dans le système de fichiers.
Description
A singleton for saving resource types to the filesystem.
It uses the many ResourceFormatSaver classes registered in the engine (either built-in or from a plugin) to save resource data to text-based (e.g. .tres or .tscn) or binary files (e.g. .res or .scn).
Méthodes
void |
add_resource_format_saver(format_saver: ResourceFormatSaver, at_front: bool = false) |
get_resource_id_for_path(path: String, generate: bool = false) |
|
void |
remove_resource_format_saver(format_saver: ResourceFormatSaver) |
save(resource: Resource, path: String = "", flags: BitField[SaverFlags] = 0) |
|
Énumérations
flags SaverFlags: 🔗
SaverFlags FLAG_NONE = 0
Aucune option d'enregistrement de ressource.
SaverFlags FLAG_RELATIVE_PATHS = 1
Enregistre la ressource avec un chemin relatif à la scène qui l'utilise.
SaverFlags FLAG_BUNDLE_RESOURCES = 2
Regroupe les ressources externes.
SaverFlags FLAG_CHANGE_PATH = 4
Change le chemin Resource.resource_path de la ressource enregistrée pour correspondre à son nouvel emplacement.
SaverFlags FLAG_OMIT_EDITOR_PROPERTIES = 8
Ne sauvegarde pas les méta-données spécifiques à l'éditeur (commençant par __editor).
SaverFlags FLAG_SAVE_BIG_ENDIAN = 16
Save as big endian (see FileAccess.big_endian).
SaverFlags FLAG_COMPRESS = 32
Compress the resource on save using FileAccess.COMPRESSION_ZSTD. Only available for binary resource types.
SaverFlags FLAG_REPLACE_SUBRESOURCE_PATHS = 64
Remplace les chemins des sous-ressources sauvegardées (voir Resource.take_over_path()).
Descriptions des méthodes
void add_resource_format_saver(format_saver: ResourceFormatSaver, at_front: bool = false) 🔗
Enregistre un nouveau ResourceFormatSaver. Le ResourceSaver utilisera le ResourceFormatSaver comme décrit dans save().
Cette méthode est effectuée implicitement pour les ResourceFormatSavers écrits en GDScript (voir ResourceFormatSaver pour plus d'informations).
PackedStringArray get_recognized_extensions(type: Resource) 🔗
Renvoie la liste des extensions possibles pour enregistrer une ressource de ce type.
int get_resource_id_for_path(path: String, generate: bool = false) 🔗
Returns the resource ID for the given path. If generate is true, a new resource ID will be generated if one for the path is not found. If generate is false and the path is not found, ResourceUID.INVALID_ID is returned.
void remove_resource_format_saver(format_saver: ResourceFormatSaver) 🔗
Désenregistre le ResourceFormatSaver donné.
Error save(resource: Resource, path: String = "", flags: BitField[SaverFlags] = 0) 🔗
Saves a resource to disk to the given path, using a ResourceFormatSaver that recognizes the resource object. If path is empty, ResourceSaver will try to use Resource.resource_path.
The flags bitmask can be specified to customize the save behavior.
Returns @GlobalScope.OK on success.
Note: When the project is running, any generated UID associated with the resource will not be saved as the required code is only executed in editor mode.
Error set_uid(resource: String, uid: int) 🔗
Sets the UID of the given resource path to uid. You can generate a new UID using ResourceUID.create_id().
Since resources will normally get a UID automatically, this method is only useful in very specific cases.