ResourceSaver

Inherits: Object

Singleton for saving Godot-specific resource types.

Description

Singleton for saving Godot-specific resource types to the filesystem.

It uses the many ResourceFormatSaver classes registered in the engine (either built-in or from a plugin) to save engine-specific resource data to text-based (e.g. .tres or .tscn) or binary files (e.g. .res or .scn).

Methods

PoolStringArray get_recognized_extensions ( Resource type )
Error save ( String path, Resource resource, SaverFlags flags=0 )

Enumerations

enum SaverFlags:

  • FLAG_RELATIVE_PATHS = 1 --- Save the resource with a path relative to the scene which uses it.
  • FLAG_BUNDLE_RESOURCES = 2 --- Bundles external resources.
  • FLAG_CHANGE_PATH = 4 --- Changes the Resource.resource_path of the saved resource to match its new location.
  • FLAG_OMIT_EDITOR_PROPERTIES = 8 --- Do not save editor-specific metadata (identified by their __editor prefix).
  • FLAG_SAVE_BIG_ENDIAN = 16 --- Save as big endian (see File.endian_swap).
  • FLAG_COMPRESS = 32 --- Compress the resource on save using File.COMPRESSION_ZSTD. Only available for binary resource types.
  • FLAG_REPLACE_SUBRESOURCE_PATHS = 64 --- Take over the paths of the saved subresources (see Resource.take_over_path).

Method Descriptions

PoolStringArray get_recognized_extensions ( Resource type )

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

Error save ( String path, Resource resource, SaverFlags flags=0 )

Saves a resource to disk to the given path, using a ResourceFormatSaver that recognizes the resource object.

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

Returns @GlobalScope.OK on success.

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/3.2/classes/class_resourcesaver.html