Documentation
¶
Overview ¶
The engine can save resources when you do it from the editor, or when you use the graphics.gd/classdb/ResourceSaver singleton. This is accomplished thanks to multiple [graphics.gd/classdb/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 graphics.gd/classdb/ResourceFormatLoader.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResourceFormatSaver ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
type Instance [1]gdclass.ResourceFormatSaver
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResourceFormatSaver ¶
type Interface ¶
type Interface interface { // 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. Save(resource Resource.Instance, path string, flags int) error // Sets a new UID for the resource at the given 'path'. Returns [Ok] on success, or an [Error] constant in case of failure. SetUid(path string, uid int) error // Returns whether the given resource object can be saved by this saver. Recognize(resource Resource.Instance) bool // Returns the list of extensions available for saving the resource object, provided it is recognized (see [Interface.Recognize]). GetRecognizedExtensions(resource Resource.Instance) []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 [Interface.GetRecognizedExtensions]. RecognizePath(resource Resource.Instance, path string) bool }