Class ResourceSaver
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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
).
public static class ResourceSaver
- Inheritance
-
ResourceSaver
- Inherited Members
Properties
Singleton
public static ResourceSaverInstance Singleton { get; }
Property Value
Methods
AddResourceFormatSaver(ResourceFormatSaver, bool)
Registers a new ResourceFormatSaver. The ResourceSaver will use the ResourceFormatSaver as described in Save(Resource, string, SaverFlags).
This method is performed implicitly for ResourceFormatSavers written in GDScript (see ResourceFormatSaver for more information).
public static void AddResourceFormatSaver(ResourceFormatSaver formatSaver, bool atFront = false)
Parameters
formatSaver
ResourceFormatSaveratFront
bool
GetRecognizedExtensions(Resource)
Returns the list of extensions available for saving a resource of a given type.
public static string[] GetRecognizedExtensions(Resource type)
Parameters
type
Resource
Returns
- string[]
RemoveResourceFormatSaver(ResourceFormatSaver)
Unregisters the given ResourceFormatSaver.
public static void RemoveResourceFormatSaver(ResourceFormatSaver formatSaver)
Parameters
formatSaver
ResourceFormatSaver
Save(Resource, string, SaverFlags)
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 ResourcePath.
The flags
bitmask can be specified to customize the save behavior using ResourceSaver.SaverFlags flags.
Returns 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.
public static Error Save(Resource resource, string path = "", ResourceSaver.SaverFlags flags = SaverFlags.None)
Parameters
resource
Resourcepath
stringflags
ResourceSaver.SaverFlags