Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ResourceFormatSaver

Inherits: RefCounted < Object

Saves a specific resource type to a file.

Description

The engine can save resources when you do it from the editor, or when you use the ResourceSaver singleton. This is accomplished thanks to multiple ResourceFormatSavers, each handling its own format and called automatically by the engine.

By default, Godot saves resources as .tres (text-based), .res (binary) or another built-in format, but you can choose to create your own format by extending this class. Be sure to respect the documented return types and values. You should give it a global class name with class_name for it to be registered. Like built-in ResourceFormatSavers, it will be called automatically when saving resources of its recognized type(s). You may also implement a ResourceFormatLoader.

Methods

PackedStringArray

_get_recognized_extensions ( Resource resource ) virtual const

bool

_recognize ( Resource resource ) virtual const

bool

_recognize_path ( Resource resource, String path ) virtual const

Error

_save ( Resource resource, String path, int flags ) virtual

Error

_set_uid ( String path, int uid ) virtual


Method Descriptions

PackedStringArray _get_recognized_extensions ( Resource resource ) virtual const

Returns the list of extensions available for saving the resource object, provided it is recognized (see _recognize).


bool _recognize ( Resource resource ) virtual const

Returns whether the given resource object can be saved by this saver.


bool _recognize_path ( Resource resource, String path ) virtual const

Returns true if this saver handles a given save path and false otherwise.

If this method is not implemented, the default