0.2.0-dev Download ZIP
55 lines ·3.1 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="ResourceFormatSaver" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Saves a specific resource type to a file. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | 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. |
| 8 | By default, Godot saves resources as [code].tres[/code] (text-based), [code].res[/code] (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 [code]class_name[/code] 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]. |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="_get_recognized_extensions" qualifiers="virtual const"> |
| 14 | <return type="PackedStringArray" /> |
| 15 | <param index="0" name="resource" type="Resource" /> |
| 16 | <description> |
| 17 | Returns the list of extensions available for saving the resource object, provided it is recognized (see [method _recognize]). |
| 18 | </description> |
| 19 | </method> |
| 20 | <method name="_recognize" qualifiers="virtual const"> |
| 21 | <return type="bool" /> |
| 22 | <param index="0" name="resource" type="Resource" /> |
| 23 | <description> |
| 24 | Returns whether the given resource object can be saved by this saver. |
| 25 | </description> |
| 26 | </method> |
| 27 | <method name="_recognize_path" qualifiers="virtual const"> |
| 28 | <return type="bool" /> |
| 29 | <param index="0" name="resource" type="Resource" /> |
| 30 | <param index="1" name="path" type="String" /> |
| 31 | <description> |
| 32 | Returns [code]true[/code] if this saver handles a given save path and [code]false[/code] otherwise. |
| 33 | If this method is not implemented, the default behavior returns whether the path's extension is within the ones provided by [method _get_recognized_extensions]. |
| 34 | </description> |
| 35 | </method> |
| 36 | <method name="_save" qualifiers="virtual"> |
| 37 | <return type="int" enum="Error" /> |
| 38 | <param index="0" name="resource" type="Resource" /> |
| 39 | <param index="1" name="path" type="String" /> |
| 40 | <param index="2" name="flags" type="int" /> |
| 41 | <description> |
| 42 | Saves the given resource object to a file at the target [param path]. [param flags] is a bitmask composed with [enum ResourceSaver.SaverFlags] constants. |
| 43 | Returns [constant OK] on success, or an [enum Error] constant in case of failure. |
| 44 | </description> |
| 45 | </method> |
| 46 | <method name="_set_uid" qualifiers="virtual"> |
| 47 | <return type="int" enum="Error" /> |
| 48 | <param index="0" name="path" type="String" /> |
| 49 | <param index="1" name="uid" type="int" /> |
| 50 | <description> |
| 51 | Sets a new UID for the resource at the given [param path]. Returns [constant OK] on success, or an [enum Error] constant in case of failure. |
| 52 | </description> |
| 53 | </method> |
| 54 | </methods> |
| 55 | </class> |