Table of Contents

Class ResourceSaver

A singleton for saving Resources to the filesystem.

Inheritance
ResourceSaver

Remarks

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).

Methods

add_resource_format_saver(ResourceFormatSaver, bool)

Registers a new ResourceFormatSaver. The ResourceSaver will use the ResourceFormatSaver as described in ResourceSaver.save.

This method is performed implicitly for ResourceFormatSavers written in GDScript (see ResourceFormatSaver for more information).

void add_resource_format_saver(ResourceFormatSaver format_saver, bool at_front)

Parameters

format_saver ResourceFormatSaver
at_front bool

get_recognized_extensions(Resource)

Returns the list of extensions available for saving a resource of a given type.

PackedStringArray get_recognized_extensions(Resource type)

Parameters

type Resource

get_resource_id_for_path(String, bool)

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, INVALID_ID is returned.

int get_resource_id_for_path(String path, bool generate)

Parameters

path String
generate bool

remove_resource_format_saver(ResourceFormatSaver)

Unregisters the given ResourceFormatSaver.

void remove_resource_format_saver(ResourceFormatSaver format_saver)

Parameters

format_saver ResourceFormatSaver

save(Resource, String, int)

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_path.

The flags bitmask can be specified to customize the save behavior using SaverFlags flags.

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.

int save(Resource resource, String path, int flags)

Parameters

resource Resource
path String
flags int