Documentation
¶
Overview ¶
A singleton for saving resource types to the filesystem.
It uses the many graphics.gd/classdb/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).
Index ¶
- func AddResourceFormatSaver(format_saver ResourceFormatSaver.Instance, at_front bool)
- func AddResourceFormatSaverOptions(format_saver ResourceFormatSaver.Instance, at_front bool)
- func Advanced() class
- func GetRecognizedExtensions(atype Resource.Instance) []string
- func GetResourceIdForPath(path string, generate bool) int
- func GetResourceIdForPathOptions(path string, generate bool) int
- func RemoveResourceFormatSaver(format_saver ResourceFormatSaver.Instance)
- func Save(resource Resource.Instance, path string, flags SaverFlags) error
- func SaveOptions(resource Resource.Instance, path string, flags SaverFlags) error
- func SetUid(resource string, uid int) error
- type Extension
- type ID
- type Instance
- type SaverFlags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddResourceFormatSaver ¶
func AddResourceFormatSaver(format_saver ResourceFormatSaver.Instance, at_front bool)
Registers a new graphics.gd/classdb/ResourceFormatSaver. The ResourceSaver will use the ResourceFormatSaver as described in Save.
This method is performed implicitly for ResourceFormatSavers written in GDScript (see graphics.gd/classdb/ResourceFormatSaver for more information).
func AddResourceFormatSaverOptions ¶
func AddResourceFormatSaverOptions(format_saver ResourceFormatSaver.Instance, at_front bool)
Registers a new graphics.gd/classdb/ResourceFormatSaver. The ResourceSaver will use the ResourceFormatSaver as described in Save.
This method is performed implicitly for ResourceFormatSavers written in GDScript (see graphics.gd/classdb/ResourceFormatSaver for more information).
func Advanced ¶
func Advanced() class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
func GetRecognizedExtensions ¶
Returns the list of extensions available for saving a resource of a given type.
func GetResourceIdForPath ¶
Returns the resource ID for the given path. If 'generate' is true, a new resource ID will be generated if one for the path is not found. If 'generate' is false and the path is not found, [Resourceuid.InvalidId] is returned.
func GetResourceIdForPathOptions ¶
Returns the resource ID for the given path. If 'generate' is true, a new resource ID will be generated if one for the path is not found. If 'generate' is false and the path is not found, [Resourceuid.InvalidId] is returned.
func RemoveResourceFormatSaver ¶
func RemoveResourceFormatSaver(format_saver ResourceFormatSaver.Instance)
Unregisters the given graphics.gd/classdb/ResourceFormatSaver.
func Save ¶
func Save(resource Resource.Instance, path string, flags SaverFlags) error
Saves a resource to disk to the given path, using a graphics.gd/classdb/ResourceFormatSaver that recognizes the resource object. If 'path' is empty, graphics.gd/classdb/ResourceSaver will try to use graphics.gd/classdb/Resource.Instance.ResourcePath.
The 'flags' bitmask can be specified to customize the save behavior.
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.
func SaveOptions ¶
func SaveOptions(resource Resource.Instance, path string, flags SaverFlags) error
Saves a resource to disk to the given path, using a graphics.gd/classdb/ResourceFormatSaver that recognizes the resource object. If 'path' is empty, graphics.gd/classdb/ResourceSaver will try to use graphics.gd/classdb/Resource.Instance.ResourcePath.
The 'flags' bitmask can be specified to customize the save behavior.
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.
Types ¶
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
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 Instance ¶
type Instance [1]gdclass.ResourceSaver
Instance of the class with convieniently typed arguments and results.
type SaverFlags ¶
type SaverFlags int //gd:ResourceSaver.SaverFlags
const ( // No resource saving option. FlagNone SaverFlags = 0 // Save the resource with a path relative to the scene which uses it. FlagRelativePaths SaverFlags = 1 // Bundles external resources. FlagBundleResources SaverFlags = 2 // Changes the [graphics.gd/classdb/Resource.Instance.ResourcePath] of the saved resource to match its new location. FlagChangePath SaverFlags = 4 // Do not save editor-specific metadata (identified by their __editor prefix). FlagOmitEditorProperties SaverFlags = 8 // Save as big endian (see [graphics.gd/classdb/FileAccess.Instance.BigEndian]). FlagSaveBigEndian SaverFlags = 16 // Compress the resource on save using [Fileaccess.CompressionZstd]. Only available for binary resource types. FlagCompress SaverFlags = 32 // Take over the paths of the saved subresources (see [graphics.gd/classdb/Resource.Instance.TakeOverPath]). FlagReplaceSubresourcePaths SaverFlags = 64 )