ResourceFormatSaver
Saves a specific resource type to a file.
ResourceFormatSaver.swift:14class ResourceFormatSaver
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 ResourceFormatSaver
s, 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
.
Superclasses
class RefCounted
Base class for reference-counted objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
Show implementation details (5)
Hide implementation details
func _getRecognizedExtensions(resource: Resource?
) -> PackedStringArray Returns the list of extensions available for saving the resource object, provided it is recognized (see
_recognize(resource:)
).func _recognize(resource: Resource?
) -> Bool Returns whether the given resource object can be saved by this saver.
func _recognizePath(resource: Resource?, path: String
) -> Bool Returns
true
if this saver handles a given save path andfalse
otherwise.func _save(resource: Resource?, path: String, flags: UInt32
) -> GodotError Saves the given resource object to a file at the target
path
.flags
is a bitmask composed withResourceSaver.SaverFlags
constants.func _setUid(path: String, uid: Int
) -> GodotError Sets a new UID for the resource at the given
path
. Returnsok
on success, or anGodotError
constant in case of failure.