Class ResourceFormatSaver
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class ResourceFormatSaver : RefCounted, IDisposable
- Inheritance
-
ResourceFormatSaver
- Implements
- Inherited Members
Constructors
ResourceFormatSaver()
public ResourceFormatSaver()
Methods
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
_GetRecognizedExtensions(Resource)
Returns the list of extensions available for saving the resource object, provided it is recognized (see _Recognize(Resource)).
public virtual string[] _GetRecognizedExtensions(Resource resource)
Parameters
resource
Resource
Returns
- string[]
_Recognize(Resource)
Returns whether the given resource object can be saved by this saver.
public virtual bool _Recognize(Resource resource)
Parameters
resource
Resource
Returns
_RecognizePath(Resource, string)
Returns true
if this saver handles a given save path and false
otherwise.
If this method is not implemented, the default behavior returns whether the path's extension is within the ones provided by _GetRecognizedExtensions(Resource).
public virtual bool _RecognizePath(Resource resource, string path)
Parameters
Returns
_Save(Resource, string, uint)
Saves the given resource object to a file at the target path
. flags
is a bitmask composed with ResourceSaver.SaverFlags constants.
Returns Ok on success, or an Error constant in case of failure.
public virtual Error _Save(Resource resource, string path, uint flags)
Parameters
Returns
_SetUid(string, long)
Sets a new UID for the resource at the given path
. Returns Ok on success, or an Error constant in case of failure.
public virtual Error _SetUid(string path, long uid)