0.2.0-dev Download ZIP
92 lines ·4.8 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="ResourceSaver" inherits="Object" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A singleton for saving [Resource]s to the filesystem. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | A singleton for saving resource types to the filesystem. |
| 8 | 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. [code].tres[/code] or [code].tscn[/code]) or binary files (e.g. [code].res[/code] or [code].scn[/code]). |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="add_resource_format_saver"> |
| 14 | <return type="void" /> |
| 15 | <param index="0" name="format_saver" type="ResourceFormatSaver" /> |
| 16 | <param index="1" name="at_front" type="bool" default="false" /> |
| 17 | <description> |
| 18 | Registers a new [ResourceFormatSaver]. The ResourceSaver will use the ResourceFormatSaver as described in [method save]. |
| 19 | This method is performed implicitly for ResourceFormatSavers written in GDScript (see [ResourceFormatSaver] for more information). |
| 20 | </description> |
| 21 | </method> |
| 22 | <method name="get_recognized_extensions"> |
| 23 | <return type="PackedStringArray" /> |
| 24 | <param index="0" name="type" type="Resource" /> |
| 25 | <description> |
| 26 | Returns the list of extensions available for saving a resource of a given type. |
| 27 | </description> |
| 28 | </method> |
| 29 | <method name="get_resource_id_for_path"> |
| 30 | <return type="int" /> |
| 31 | <param index="0" name="path" type="String" /> |
| 32 | <param index="1" name="generate" type="bool" default="false" /> |
| 33 | <description> |
| 34 | Returns the resource ID for the given path. If [param generate] is [code]true[/code], a new resource ID will be generated if one for the path is not found. If [param generate] is [code]false[/code] and the path is not found, [constant ResourceUID.INVALID_ID] is returned. |
| 35 | </description> |
| 36 | </method> |
| 37 | <method name="remove_resource_format_saver"> |
| 38 | <return type="void" /> |
| 39 | <param index="0" name="format_saver" type="ResourceFormatSaver" /> |
| 40 | <description> |
| 41 | Unregisters the given [ResourceFormatSaver]. |
| 42 | </description> |
| 43 | </method> |
| 44 | <method name="save"> |
| 45 | <return type="int" enum="Error" /> |
| 46 | <param index="0" name="resource" type="Resource" /> |
| 47 | <param index="1" name="path" type="String" default="""" /> |
| 48 | <param index="2" name="flags" type="int" enum="ResourceSaver.SaverFlags" is_bitfield="true" default="0" /> |
| 49 | <description> |
| 50 | Saves a resource to disk to the given path, using a [ResourceFormatSaver] that recognizes the resource object. If [param path] is empty, [ResourceSaver] will try to use [member Resource.resource_path]. |
| 51 | The [param flags] bitmask can be specified to customize the save behavior. |
| 52 | Returns [constant OK] on success. |
| 53 | [b]Note:[/b] 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. |
| 54 | </description> |
| 55 | </method> |
| 56 | <method name="set_uid"> |
| 57 | <return type="int" enum="Error" /> |
| 58 | <param index="0" name="resource" type="String" /> |
| 59 | <param index="1" name="uid" type="int" /> |
| 60 | <description> |
| 61 | Sets the UID of the given [param resource] path to [param uid]. You can generate a new UID using [method ResourceUID.create_id]. |
| 62 | Since resources will normally get a UID automatically, this method is only useful in very specific cases. |
| 63 | </description> |
| 64 | </method> |
| 65 | </methods> |
| 66 | <constants> |
| 67 | <constant name="FLAG_NONE" value="0" enum="SaverFlags" is_bitfield="true"> |
| 68 | No resource saving option. |
| 69 | </constant> |
| 70 | <constant name="FLAG_RELATIVE_PATHS" value="1" enum="SaverFlags" is_bitfield="true"> |
| 71 | Save the resource with a path relative to the scene which uses it. |
| 72 | </constant> |
| 73 | <constant name="FLAG_BUNDLE_RESOURCES" value="2" enum="SaverFlags" is_bitfield="true"> |
| 74 | Bundles external resources. |
| 75 | </constant> |
| 76 | <constant name="FLAG_CHANGE_PATH" value="4" enum="SaverFlags" is_bitfield="true"> |
| 77 | Changes the [member Resource.resource_path] of the saved resource to match its new location. |
| 78 | </constant> |
| 79 | <constant name="FLAG_OMIT_EDITOR_PROPERTIES" value="8" enum="SaverFlags" is_bitfield="true"> |
| 80 | Do not save editor-specific metadata (identified by their [code]__editor[/code] prefix). |
| 81 | </constant> |
| 82 | <constant name="FLAG_SAVE_BIG_ENDIAN" value="16" enum="SaverFlags" is_bitfield="true"> |
| 83 | Save as big endian (see [member FileAccess.big_endian]). |
| 84 | </constant> |
| 85 | <constant name="FLAG_COMPRESS" value="32" enum="SaverFlags" is_bitfield="true"> |
| 86 | Compress the resource on save using [constant FileAccess.COMPRESSION_ZSTD]. Only available for binary resource types. |
| 87 | </constant> |
| 88 | <constant name="FLAG_REPLACE_SUBRESOURCE_PATHS" value="64" enum="SaverFlags" is_bitfield="true"> |
| 89 | Take over the paths of the saved subresources (see [method Resource.take_over_path]). |
| 90 | </constant> |
| 91 | </constants> |
| 92 | </class> |