Class ResourceSaverInstance
- 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
).
[GodotClassName("ResourceSaver")]
public class ResourceSaverInstance : GodotObject, IDisposable
- Inheritance
-
ResourceSaverInstance
- Implements
- Inherited Members
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 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 string[] GetRecognizedExtensions(Resource type)
Parameters
type
Resource
Returns
- string[]
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RemoveResourceFormatSaver(ResourceFormatSaver)
Unregisters the given ResourceFormatSaver.
public 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 Error Save(Resource resource, string path = "", ResourceSaver.SaverFlags flags = SaverFlags.None)
Parameters
resource
Resourcepath
stringflags
ResourceSaver.SaverFlags